[patch i386 mingw]: PR/39492

Jakub Jelinek jakub@redhat.com
Tue Mar 31 10:28:00 GMT 2009


On Tue, Mar 31, 2009 at 11:14:05AM +0200, Kai Tietz wrote:
> Hello,
> 
> for PR/39492 I prefer to use hexadecimal representation for the
> process ID in the unique name. By this the maximal size of the char
> array is predictable as sizeof (long) * 2.
> 
> ChangeLog
> 2009-03-31  Kai Tietz  <kai.tietz@onevision.com>
> 		  Andrey Galkin <agalkin@hypercom.com>
> 
> 	PR/39492
> 	* config/i386/host-mingw32.c (mingw32_gt_pch_use_address):
> 	Make object_name unique for each process.
> 
> I tested this patch  for 4.4. I'll apply this patch in 8 hours for 4.4
> and trunk, when nobody has objections.

+  const char object_name_prefix[] = "Local\\MinGWGCCPCH-";
+
+  /* Allocate enough space for name prefix and max possible DWORD
+    hexadecimal representation.  */
+  char object_name[sizeof( object_name_prefix ) sizeof (long) * 2 + 1];

I wonder how this will compile at all, there is no + in between
the two sizeofs.  Also, the +1 is unnecessary, the first sizeof already
includes the terminating '\0' (unlike strlen).  And formatting is wrong.
Anyway, IMHO it is unnecessary to use %s and a separate const char var,
just
#define OBJECT_NAME_FMT "Local\\MinGWGCCPCH-%lx"
char object_name[sizeof (OBJECT_NAME_FMT) + 2 * sizeof (long) - 3];
snprintf (object_name, sizeof object_name, OBJECT_NAME_FMT, ...);

	Jakub



More information about the Gcc-patches mailing list