[hurd,commited] hurd sendmsg: Fix warning on calling CMSG_*HDR
Commit Message
---
sysdeps/mach/hurd/sendmsg.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Dez 29 2019, Samuel Thibault wrote:
> diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c
> index 0c19b3223c..3d7317cec4 100644
> --- a/sysdeps/mach/hurd/sendmsg.c
> +++ b/sysdeps/mach/hurd/sendmsg.c
> @@ -108,7 +108,7 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
>
> /* Allocate enough room for ports. */
> cmsg = CMSG_FIRSTHDR (message);
> - for (; cmsg; cmsg = CMSG_NXTHDR (message, cmsg))
> + for (; cmsg; cmsg = CMSG_NXTHDR ((struct msghdr *) message, cmsg))
Why is the first argument of __cmsg_nxthdr not const?
Andreas.
Andreas Schwab, le dim. 29 déc. 2019 18:12:02 +0100, a ecrit:
> > - for (; cmsg; cmsg = CMSG_NXTHDR (message, cmsg))
> > + for (; cmsg; cmsg = CMSG_NXTHDR ((struct msghdr *) message, cmsg))
>
> Why is the first argument of __cmsg_nxthdr not const?
I don't know, it is so on other systems as well.
I guess an issue is that if it was const, CMSG_NXTHDR would only
be allowed to return a const, and the caller might actually want a
non-const (and it passed a non-const). So it'd be a choice between
cast-parameter vs cast-returned-value.
Samuel
On Dez 29 2019, Samuel Thibault wrote:
> Andreas Schwab, le dim. 29 déc. 2019 18:12:02 +0100, a ecrit:
>> > - for (; cmsg; cmsg = CMSG_NXTHDR (message, cmsg))
>> > + for (; cmsg; cmsg = CMSG_NXTHDR ((struct msghdr *) message, cmsg))
>>
>> Why is the first argument of __cmsg_nxthdr not const?
>
> I don't know, it is so on other systems as well.
>
> I guess an issue is that if it was const, CMSG_NXTHDR would only
> be allowed to return a const,
The return value is not based on the first argument.
Andreas.
Andreas Schwab, le dim. 29 déc. 2019 19:08:37 +0100, a ecrit:
> On Dez 29 2019, Samuel Thibault wrote:
>
> > Andreas Schwab, le dim. 29 déc. 2019 18:12:02 +0100, a ecrit:
> >> > - for (; cmsg; cmsg = CMSG_NXTHDR (message, cmsg))
> >> > + for (; cmsg; cmsg = CMSG_NXTHDR ((struct msghdr *) message, cmsg))
> >>
> >> Why is the first argument of __cmsg_nxthdr not const?
> >
> > I don't know, it is so on other systems as well.
> >
> > I guess an issue is that if it was const, CMSG_NXTHDR would only
> > be allowed to return a const,
>
> The return value is not based on the first argument.
Oh, right. Then I don't know, I just see it so everywhere else.
Samuel
* Andreas Schwab:
> On Dez 29 2019, Samuel Thibault wrote:
>
>> diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c
>> index 0c19b3223c..3d7317cec4 100644
>> --- a/sysdeps/mach/hurd/sendmsg.c
>> +++ b/sysdeps/mach/hurd/sendmsg.c
>> @@ -108,7 +108,7 @@ __libc_sendmsg (int fd, const struct msghdr
>> *message, int flags)
>>
>> /* Allocate enough room for ports. */
>> cmsg = CMSG_FIRSTHDR (message);
>> - for (; cmsg; cmsg = CMSG_NXTHDR (message, cmsg))
>> + for (; cmsg; cmsg = CMSG_NXTHDR ((struct msghdr *) message, cmsg))
>
> Why is the first argument of __cmsg_nxthdr not const?
Some programmers expect that CMSG_NXTHDR can be used to construct
ancillary data. See bug 13500.
On Dez 29 2019, Florian Weimer wrote:
> * Andreas Schwab:
>
>> On Dez 29 2019, Samuel Thibault wrote:
>>
>>> diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c
>>> index 0c19b3223c..3d7317cec4 100644
>>> --- a/sysdeps/mach/hurd/sendmsg.c
>>> +++ b/sysdeps/mach/hurd/sendmsg.c
>>> @@ -108,7 +108,7 @@ __libc_sendmsg (int fd, const struct msghdr
>>> *message, int flags)
>>>
>>> /* Allocate enough room for ports. */
>>> cmsg = CMSG_FIRSTHDR (message);
>>> - for (; cmsg; cmsg = CMSG_NXTHDR (message, cmsg))
>>> + for (; cmsg; cmsg = CMSG_NXTHDR ((struct msghdr *) message, cmsg))
>>
>> Why is the first argument of __cmsg_nxthdr not const?
>
> Some programmers expect that CMSG_NXTHDR can be used to construct
> ancillary data. See bug 13500.
How is that related to the first argument?
Andreas.
@@ -108,7 +108,7 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
/* Allocate enough room for ports. */
cmsg = CMSG_FIRSTHDR (message);
- for (; cmsg; cmsg = CMSG_NXTHDR (message, cmsg))
+ for (; cmsg; cmsg = CMSG_NXTHDR ((struct msghdr *) message, cmsg))
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS)
nports += (cmsg->cmsg_len - CMSG_ALIGN (sizeof (struct cmsghdr)))
/ sizeof (int);
@@ -119,7 +119,7 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
nports = 0;
for (cmsg = CMSG_FIRSTHDR (message);
cmsg;
- cmsg = CMSG_NXTHDR (message, cmsg))
+ cmsg = CMSG_NXTHDR ((struct msghdr *) message, cmsg))
{
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS)
{