Bug 97051 - get_mempolicy(2) inconsistent with numaif.h
Summary: get_mempolicy(2) inconsistent with numaif.h
Status: RESOLVED CODE_FIX
Alias: None
Product: Documentation
Classification: Unclassified
Component: man-pages (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: documentation_man-pages@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-21 22:28 UTC by Nadav Har'El
Modified: 2017-05-30 03:06 UTC (History)
2 users (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Nadav Har'El 2015-04-21 22:28:38 UTC
get_mempolicy(2)'s synopsis is:

       #include <numaif.h>

       int get_mempolicy(int *mode, unsigned long *nodemask,
                         unsigned long maxnode, unsigned long addr,
                         unsigned long flags);

However, the actual prototype in numif.h (and implementation in numactl's syscall.c) is subtly different:

       long get_mempolicy(int *policy, const unsigned long *nmask,
                        unsigned long maxnode, void *addr, int flags);

The funny thing is, that prototype is isn't quite right either - it pretends nmask is a const pointer, but it most definitely isn't, and the data pointed by it get written to. But that isn't a man-page bug.
Comment 1 Michael Kerrisk 2015-05-05 09:19:10 UTC
Andi, could you comment on this bug?

Thanks,

Michael

On 22 April 2015 at 00:28,  <bugzilla-daemon@bugzilla.kernel.org> wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=97051
>
>             Bug ID: 97051
>            Summary: get_mempolicy(2) inconsistent with numaif.h
>            Product: Documentation
>            Version: unspecified
>           Hardware: All
>                 OS: Linux
>             Status: NEW
>           Severity: normal
>           Priority: P1
>          Component: man-pages
>           Assignee: documentation_man-pages@kernel-bugs.osdl.org
>           Reporter: nyh@math.technion.ac.il
>         Regression: No
>
> get_mempolicy(2)'s synopsis is:
>
>        #include <numaif.h>
>
>        int get_mempolicy(int *mode, unsigned long *nodemask,
>                          unsigned long maxnode, unsigned long addr,
>                          unsigned long flags);
>
> However, the actual prototype in numif.h (and implementation in numactl's
> syscall.c) is subtly different:
>
>        long get_mempolicy(int *policy, const unsigned long *nmask,
>                         unsigned long maxnode, void *addr, int flags);
>
> The funny thing is, that prototype is isn't quite right either - it pretends
> nmask is a const pointer, but it most definitely isn't, and the data pointed
> by
> it get written to. But that isn't a man-page bug.
>
> --
> You are receiving this mail because:
> You are watching the assignee of the bug.
Comment 2 Michael Kerrisk 2016-11-09 13:21:20 UTC
Andi, Could you comment on this bug?
Comment 3 Andi Kleen 2016-11-16 01:31:03 UTC
Yes the manpage version is better and the const is incorrect.
Should probably fix the version in numactl
Comment 4 Andi Kleen 2017-05-25 20:39:48 UTC
Sorry for the delay.

I fixed numactl to drop the const from the get_mempolicy prototype, and also changed flags to unsigned.

I didn't change the addr argument to unsigned long because that would cause warnings in existing code. 

I would recommend to change the manpage to this prototype to match numaif.h:

long get_mempolicy(int *mode, unsigned long *nmask,
                        unsigned long maxnode, void *addr, unsigned flags);
Comment 5 Michael Kerrisk 2017-05-30 03:06:34 UTC
(In reply to Andi Kleen from comment #4)
> Sorry for the delay.
> 
> I fixed numactl to drop the const from the get_mempolicy prototype, and also
> changed flags to unsigned.
> 
> I didn't change the addr argument to unsigned long because that would cause
> warnings in existing code. 
> 
> I would recommend to change the manpage to this prototype to match numaif.h:
> 
> long get_mempolicy(int *mode, unsigned long *nmask,
>                         unsigned long maxnode, void *addr, unsigned flags);

Okay -- I've made that change to the man page.

I'll close this bug now. Nadav Har'El, if you think someting is still wrong, please reopen.

Thanks,

Michael

Note You need to log in before you can comment on or make changes to this bug.