This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch i386 mingw]: PR/39492
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Kai Tietz <ktietz70 at googlemail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Andrey Galkin <agalkin at hypercom dot com>
- Date: Tue, 31 Mar 2009 11:29:38 +0200
- Subject: Re: [patch i386 mingw]: PR/39492
- References: <90baa01f0903310214x4c3b85e1r64673a1e9a8e4675@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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