This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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] constify to_attach


>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

>> -  dummy = args;
>> +  dummy = (char *) args;
>> pid = strtoul (args, &dummy, 0);
>> /* Some targets don't set errno on errors, grrr!  */
>> if ((pid == 0 && dummy == args) || dummy != &args[strlen (args)])

Pedro> errno would be necessary to catch overflow, but not to check whether
Pedro> the number was syntactically correct.  strtoul always sets *endptr to
Pedro> point to the address of the first invalid character (and never to NULL).

Pedro> So you could just remove the 'dummy' assignment.

Pedro> But I'll understand if you want to keep it.

I agree that the assignment is not necessary.

However, I left it since presumably it is based on some ancient, broken
strtoul where it was actually needed, and I didn't want to get into this
aspect of the code.

Pedro> The patch looks fine to me.

I'm pushing it now.

Tom


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