This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2.1 1/2][BZ #16274] Fix shm_open.
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 03 Dec 2013 10:09:15 -0500
- Subject: Re: [PATCH v2.1 1/2][BZ #16274] Fix shm_open.
- Authentication-results: sourceware.org; auth=none
- References: <20131129004016 dot GA19990 at domone dot podge> <5297F6B6 dot 5010609 at redhat dot com> <20131129180250 dot GA24922 at domone dot podge> <5298EF8F dot 6020700 at redhat dot com> <20131202230453 dot GA6175 at domone dot podge> <529D1AD1 dot 7080500 at redhat dot com> <20131203112032 dot GB11582 at domone dot podge>
On 12/03/2013 06:20 AM, OndÅej BÃlka wrote:
> On Mon, Dec 02, 2013 at 06:42:09PM -0500, Carlos O'Donell wrote:
>> On 12/02/2013 06:04 PM, OndÅej BÃlka wrote:
>>> On Fri, Nov 29, 2013 at 02:48:31PM -0500, Carlos O'Donell wrote:
>>>>> + if (errno != ENOSYS)
>>>>
>>>> Same question here, shouldn't this be "errno == ENOSYS"?
>>>>
>>>>> + error (EXIT_FAILURE, 0, "failed to open shared memory object: shm_open");
>>>>> +
>>>>
>>>> Suggest: "Failed to open shared memory object: shm_open unimplemented. Test skipped." wrapped appropriately.
>>>>
>>>>> perror ("failed to create a shared memory object: shm_open");
>>>>> return 0;
>>>>
>>>> Shouldn't this be `return -1;' ?
>>>>
>>>> We want to exit with 0 if the error was ENOSYS otherwise -1?
>>>>
>>>> Maybe it's just Friday and I'm confused though...
>>>>
>>> It was double negation, which is correct but bit confusing.
>>>
>>> Here is new version, a do_open function uses a existing shared object so
>>> I simply inlined it with appropriate error.
>>
>> Thanks.
>>
>>> - /* We don't regard this as a bug. Simply don't run the test. It could
>>> - means there is no such implementation or the object is already in
>>> - use in which case we don't want to disturb. */
>>> - perror ("failed to create a shared memory object: shm_open");
>>> - return 0;
>>> + /* If shm_open is unimplemented we skip the test. */
>>> + if (errno == ENOSYS)
>>> + {
>>> + perror ("shm_open unimplemented. Test skipped.");
>>> + return 0;
>>> + }
>>> + else
>>> + error (EXIT_FAILURE, 0, "failed to create shared memory object: shm_open");
>>
>> Shouldn't this be s/0/-1/g? It's a real failure?
>
> It is failure as we passed EXIT_FAILURE to status, arguments to error are:
>
> error (int status, int errnum, const char *format, ...)
>
Sorry, I forgot the order of the arguments to this function.
Let me rephrase my question more precisely.
Should we instead use:
error (EXIT_FAILURE, errno, "failed to create shared memory object: shm_open");
Such that we print:
"failed to create shared memory object: shm_open: `strerror(errno)'"
Cheers,
Carlos.