[openib-general] [PATCHv2] osm: fixing OSM_LOG_DIR and OSM_CACHE_DIR treatment

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Mon Oct 16 15:39:55 PDT 2006


Hi Hal.

[snip]
> 
> So will you supply another patch with this approach ?
> 
> -- Hal

Here it is.

--
Yevgeny

Signed-off-by:  Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>

Index: opensm/osm_db_files.c
===================================================================
--- opensm/osm_db_files.c	(revision 9827)
+++ opensm/osm_db_files.c	(working copy)
@@ -182,9 +182,7 @@ osm_db_init(
   CL_ASSERT( p_db_imp != NULL);
 
   p_db_imp->db_dir_name = getenv("OSM_CACHE_DIR");
-  if (p_db_imp->db_dir_name && (strlen(p_db_imp->db_dir_name) == 0))
-    p_db_imp->db_dir_name = NULL;
-  if ( p_db_imp->db_dir_name == NULL )
+  if (!p_db_imp->db_dir_name || !(*p_db_imp->db_dir_name))
     p_db_imp->db_dir_name = OSM_DEFAULT_CACHE_DIR;
 
   /* Create the directory if it doesn't exist */
Index: opensm/osm_subnet.c
===================================================================
--- opensm/osm_subnet.c	(revision 9827)
+++ opensm/osm_subnet.c	(working copy)
@@ -472,9 +472,7 @@ osm_subn_set_default_opt(
   p_opt->honor_guid2lid_file = FALSE;
 
   p_opt->dump_files_dir = getenv("OSM_TMP_DIR");
-  if (p_opt->dump_files_dir && (strlen(p_opt->dump_files_dir) == 0))
-    p_opt->dump_files_dir = NULL;
-  if (!p_opt->dump_files_dir)
+  if (!p_opt->dump_files_dir || !(*p_opt->dump_files_dir))
     p_opt->dump_files_dir = OSM_DEFAULT_TMP_DIR;
 
   p_opt->log_file = OSM_DEFAULT_LOG_FILE;
@@ -721,9 +719,7 @@ osm_subn_rescan_conf_file(
   char *p_key, *p_val ,*p_last;
   
   /* try to open the options file from the cache dir */
-  if (p_cache_dir && (strlen(p_cache_dir) == 0))
-    p_cache_dir = NULL;
-  if (! p_cache_dir)
+  if (!p_cache_dir || !(*p_cache_dir))
     p_cache_dir = OSM_DEFAULT_CACHE_DIR;
 
   strcpy(file_name, p_cache_dir);
@@ -774,9 +770,7 @@ osm_subn_parse_conf_file(
   char *p_key, *p_val ,*p_last;
   
   /* try to open the options file from the cache dir */
-  if (p_cache_dir && (strlen(p_cache_dir) == 0))
-    p_cache_dir = NULL;
-  if (! p_cache_dir)
+  if (!p_cache_dir || !(*p_cache_dir))
     p_cache_dir = OSM_DEFAULT_CACHE_DIR;
 
   strcpy(file_name, p_cache_dir);
@@ -1008,9 +1002,7 @@ osm_subn_write_conf_file(
   FILE *opts_file;
   
   /* try to open the options file from the cache dir */
-  if (p_cache_dir && (strlen(p_cache_dir) == 0))
-    p_cache_dir = NULL;
-  if (! p_cache_dir)
+  if (!p_cache_dir || !(*p_cache_dir))
     p_cache_dir = OSM_DEFAULT_CACHE_DIR;
 
   strcpy(file_name, p_cache_dir);




More information about the general mailing list