[PATCH v2] Cygwin: Fix error return for madvise()

Christian Franke Christian.Franke@t-online.de
Wed Jul 8 14:58:02 GMT 2026


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'.

-- 
Regards,
Christan



More information about the Cygwin-patches mailing list