Re: [PATCH v2] Cygwin: Fix error return for madvise()
Mark Geisert <[email protected]> Wed, 8 Jul 2026 14:04:58 -0700
| Newsgroups | gmane.os.cygwin.patches |
|---|---|
| Message-ID | <[email protected]> |
Hi Christian,
On 7/8/2026 7:58 AM, Christian Franke wrote:
> Mark Geisert wrote:
>> Currently madvise() and posix_madvise() are wired together as one
>> function: the latter. But their error returns should be different.
>> Make madvise a first-class export in cygwin.din.
>>
>> v2: Create madvise_worker() and have madvise() and posix_madvise()
>> call it, then handling their error returns compliant to POSIX.
>> Add a release note for 3.7.0.
>
> LGTM, thanks!
>
>
>> ...
>> -extern "C" int
>> -posix_madvise (void *addr, size_t len, int advice)
>> +static int
>> +madvise_worker (void *addr, size_t len, int advice)
>> {
>> int ret = 0;
>> /* Check parameters. */
>> @@ -1514,6 +1514,26 @@ posix_madvise (void *addr, size_t len, int advice)
>> break;
>> }
>> out:
>> + return ret;
>> +}
>
> PS: The 'goto out' could now be replaced by 'return ref'.
I prefer to keep both 'goto out' so there's just one exit from the
function to aid future debugging. Perhaps that's an old-school habit.
Cheers,
..mark