This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch i386 mingw]: PR/39492


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]