[llvm-commits] [llvm] r153538 - /llvm/trunk/runtime/libprofile/GCDAProfiling.c

NAKAMURA Takumi geek4civic at gmail.com
Tue Mar 27 17:03:51 PDT 2012


2012/3/28 Bill Wendling <isanbard at gmail.com>:
> Author: void
> Date: Tue Mar 27 16:17:04 2012
> New Revision: 153538
>
> URL: http://llvm.org/viewvc/llvm-project?rev=153538&view=rev
> Log:
> Try to use the CWD if the path to the GCDA output is not available (e.g., the
> executable has been moved to another machine). If that's not available
> (read-only or something), then exit gracefully.
> <rdar://problem/11111686>
>
> Modified:
>    llvm/trunk/runtime/libprofile/GCDAProfiling.c
>
> Modified: llvm/trunk/runtime/libprofile/GCDAProfiling.c
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/GCDAProfiling.c?rev=153538&r1=153537&r2=153538&view=diff
> ==============================================================================
> --- llvm/trunk/runtime/libprofile/GCDAProfiling.c (original)
> +++ llvm/trunk/runtime/libprofile/GCDAProfiling.c Tue Mar 27 16:17:04 2012
> @@ -113,6 +113,20 @@
>   recursive_mkdir(filename);
>   output_file = fopen(filename, "wb");
>
> +  if (!output_file) {
> +    filename[0] = '\0';  /* The size of filename should be big enough. */
> +    char *cptr = strrchr(orig_filename, '/');

It was not C89-compliant. Francois has fixed in r153549.

> +    strcat(filename, cptr ? cptr + 1 : orig_filename);
> +    output_file = fopen(filename, "wb");

Why strcat() to filename[] that is truncated to zero-length?
In this case, would it be enough to pick up the pointer rather than to
update filename[]?

cptr = (cptr ? cptr + 1 : orig_filename);
fopen(cptr, ...);

...Takumi




More information about the llvm-commits mailing list