[PATCH] Fix PR50293 - LTO plugin with space in path

Joseph S. Myers joseph@codesourcery.com
Sun Mar 3 16:48:00 GMT 2013

On Mon, 18 Feb 2013, Joey Ye wrote:

> +static char * convert_white_space (char *);

No space after "*".

> -	      linker_plugin_file_spec = find_a_file (&exec_prefixes,
> +	      char * temp_spec = find_a_file (&exec_prefixes,
>  						     LTOPLUGINSONAME, R_OK,
>  						     false);

The indentation of the following lines looks odd after this patch; unless 
that's just an effect of TABs plus quoting, make sure they are reindented 
to line up with the new position of the opening '('.

> +/* Insert back slash before spaces in orig (usually a file path), to 

Capitalize variable names when referring to the value of the variable, so 
ORIG; likewise elsewhere in this comment.  Single work "backslash".

> +   the filename should be treated as a single argument rather than being

"file name" should be two words, according to the GNU Coding Standards.

> +   This function converts and only converts all occurrance of ' ' 


> +   Return: orig if no conversion needed. orig if conversion needed but no
> +   sufficient memory for a new string. Otherwise a newly allocated string

Returning wrong results on insufficient memory doesn't make sense.  
Anyway, xmalloc always exits the program if there is insufficient memory, 
so you don't need any code to allow for that case.

> +static char * convert_white_space (char *orig)

Newline, not space, between return type and function name, so that the 
function name comes at the start of the line.

> +  if (orig == NULL) return orig;

The comment didn't mention NULL as a valid argument, and it doesn't appear 
NULL can actually be passed to this function.  So don't include code to 
handle that case.

> +  for (len=0; orig[len]; len++)

Spaces around "=".

> +    if (orig[len] == ' ' || orig[len] == '\t') number_of_space ++;

No space before "++", but put the body of the "if" on a separate line.

> +      char * new_spec = (char *)xmalloc (len + number_of_space + 1);

No space after "*".  Space in the cast after "(char *)".

> +      int j,k;

Space after ",".

> +      if (new_spec == NULL) return orig;

As discussed above, not needed.

> +      for (j=0, k=0; j<=len; j++, k++)

Spaces around "=" and "<=".

> +	  if (orig[j] == ' ' || orig[j] == '\t') new_spec[k++] = '\\';

Put the "if" both on a separate line.

> +  else return orig;

Put the "else" body on a separate line.

Joseph S. Myers

More information about the Gcc-patches mailing list