[openib-general] [PATCH] OpenSM: Change filename from subnet.lst to osm-subnet.lst

Greg Lindahl greg.lindahl at qlogic.com
Tue Nov 28 16:25:52 PST 2006


On Tue, Nov 28, 2006 at 07:02:07AM -0500, Hal Rosenstock wrote:

>     file_name =
> -      ( char * )malloc( strlen( p_mgr->p_subn->opt.dump_files_dir ) + 12 );
> +      ( char * )malloc( strlen( p_mgr->p_subn->opt.dump_files_dir ) + 16 );
>  
>     CL_ASSERT( file_name );
>  
>     strcpy( file_name, p_mgr->p_subn->opt.dump_files_dir );
> -   strcat( file_name, "/subnet.lst" );
> +   strcat( file_name, "/osm-subnet.lst" );

Instead of changing the magic number 12 to a different magic number, how about,

#define SUBNET_LIST_FILENAME "/osm-subnet.lst"

   file_name =
      (char *)malloc(strlen(p_mgr->p_subn->opt.dump_files_dir) + strlen(SUBNET_LIST_FILENAME) + 1);
...
   strcat(file_name, SUBNET_LIST_FILENAME);

Voila! No more magic number. Well, other than the 1 for the \0.

-- greg





More information about the general mailing list