@@ -358,22 +358,27 @@ static int generated_keypairs_type[MAX_KEYPAIRS];
358358static uint32_t generated_keypairs_id_mask [MAX_KEYPAIRS ];
359359static int n_generated = 0 ;
360360
361- static char * append_pub_to_fname (const char * filename ) {
362- const char pubSuffix [] = "_pub" ;
361+ static char * append_pub_to_fname (const char * filename )
362+ {
363+ const char pubSuffix [] = "_pub" ;
363364 const size_t pubSuffixLength = strlen (pubSuffix );
365+ const char * dotPosition ;
366+ size_t prefixLength ;
367+ char * newFilename ;
368+ size_t newFilenameLength ;
364369
365- const char * dotPosition = strchr (filename , '.' );
366-
367- size_t prefixLength ;
370+ dotPosition = strchr (filename , '.' );
368371 if (dotPosition != NULL ) {
369372 prefixLength = dotPosition - filename ;
370- } else {
373+ }
374+ else {
371375 prefixLength = strlen (filename );
372376 }
373377
374- size_t newFilenameLength = prefixLength + pubSuffixLength + (dotPosition ? strlen (dotPosition ) : 0 ) + 1 ;
378+ newFilenameLength = prefixLength + pubSuffixLength +
379+ (dotPosition ? strlen (dotPosition ) : 0 ) + 1 ;
375380
376- char * newFilename = (char * )malloc (newFilenameLength );
381+ newFilename = (char * )malloc (newFilenameLength );
377382 if (newFilename == NULL ) {
378383 return NULL ;
379384 }
@@ -387,8 +392,10 @@ static char *append_pub_to_fname(const char *filename) {
387392 /* Append the rest of the original filename if a period was found */
388393 if (dotPosition != NULL ) {
389394 strcpy (newFilename + prefixLength + pubSuffixLength , dotPosition );
390- } else {
391- newFilename [prefixLength + pubSuffixLength ] = '\0' ; /* Null-terminate the string if no period */
395+ }
396+ else {
397+ /* Null-terminate the string if no period */
398+ newFilename [prefixLength + pubSuffixLength ] = '\0' ;
392399 }
393400
394401 return newFilename ;
0 commit comments