Commit ef58b319 authored by Jeremy Hylton's avatar Jeremy Hylton

Use PyOS_snprintf instead of sprintf.

Also replace a switch statement with one case and a default to an
if/else.
parent 1ceb5fb9
...@@ -194,20 +194,20 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, ...@@ -194,20 +194,20 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
printf( "load_add_on( %s ) failed", fullpath ); printf( "load_add_on( %s ) failed", fullpath );
} }
switch( the_id ) { if( the_id == B_ERROR )
case B_ERROR: PyOS_snprintf( buff, sizeof(buff),
sprintf( buff, "BeOS: Failed to load %.200s", fullpath ); "BeOS: Failed to load %.200s",
break; fullpath );
default: else
sprintf( buff, "Unknown error loading %.200s", fullpath ); PyOS_snprintf( buff, sizeof(buff),
break; "Unknown error loading %.200s",
} fullpath );
PyErr_SetString( PyExc_ImportError, buff ); PyErr_SetString( PyExc_ImportError, buff );
return NULL; return NULL;
} }
sprintf(funcname, "init%.200s", shortname); PyOs_snprintf(funcname, sizeof(funcname), "init%.200s", shortname);
if( Py_VerboseFlag ) { if( Py_VerboseFlag ) {
printf( "get_image_symbol( %s )\n", funcname ); printf( "get_image_symbol( %s )\n", funcname );
} }
...@@ -224,16 +224,19 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, ...@@ -224,16 +224,19 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
switch( retval ) { switch( retval ) {
case B_BAD_IMAGE_ID: case B_BAD_IMAGE_ID:
sprintf( buff, "can't load init function for dynamic module: " PyOS_snprintf( buff, sizeof(buff),
"Invalid image ID for %.180s", fullpath ); "can't load init function for dynamic module: "
"Invalid image ID for %.180s", fullpath );
break; break;
case B_BAD_INDEX: case B_BAD_INDEX:
sprintf( buff, "can't load init function for dynamic module: " PyOS_snprintf( buff, sizeof(buff),
"Bad index for %.180s", funcname ); "can't load init function for dynamic module: "
"Bad index for %.180s", funcname );
break; break;
default: default:
sprintf( buff, "can't load init function for dynamic module: " PyOS_snprintf( buff, sizeof(buf),
"Unknown error looking up %.180s", funcname ); "can't load init function for dynamic module: "
"Unknown error looking up %.180s", funcname );
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment