NetBSD Problem Report #57871

From www@netbsd.org  Mon Jan 22 18:35:15 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 295B71A9238
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 22 Jan 2024 18:35:15 +0000 (UTC)
Message-Id: <20240122183513.7ED9C1A9239@mollari.NetBSD.org>
Date: Mon, 22 Jan 2024 18:35:13 +0000 (UTC)
From: netbsd.org@hacktivis.me
Reply-To: netbsd.org@hacktivis.me
To: gnats-bugs@NetBSD.org
Subject: CMSG_DATA uses u_char which is undefined when POSIX_C_SOURCE is set
X-Send-Pr-Version: www-1.0

>Number:         57871
>Category:       lib
>Synopsis:       CMSG_DATA uses u_char which is undefined when POSIX_C_SOURCE is set
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          feedback
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 22 18:40:00 +0000 2024
>Closed-Date:    
>Last-Modified:  Sun Feb 04 00:50:01 +0000 2024
>Originator:     Haelwenn (lanodan) Monnier
>Release:        9.3
>Organization:
>Environment:
NetBSD build 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug  4 15:30:37 UTC 2022  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
As seen in https://github.com/akash-akya/exile (commit 71a21be) where it fails with the following error (CC=clang for enough information):

```
$ mix compile
clang -Wall -Werror -Wno-unused-parameter -pedantic -std=c99 -O2 -D_POSIX_C_SOURCE=200809L c_src/spawner.c -o priv/spawner
c_src/spawner.c:72:17: error: expected expression
  memcpy((int *)CMSG_DATA(cmsg), fds, 3 * sizeof(int));
                ^
/usr/include/sys/socket.h:554:26: note: expanded from macro 'CMSG_DATA'
#define CMSG_DATA(cmsg) (__CASTV(u_char *, cmsg) + __CMSG_ASIZE)
                         ^
/usr/include/sys/cdefs.h:620:29: note: expanded from macro '__CASTV'
#define __CASTV(__dt, __st)     __CAST(__dt, __CAST(void *, __st))
                                ^
/usr/include/sys/cdefs.h:617:34: note: expanded from macro '__CAST'
#define __CAST(__dt, __st)      ((__dt)(__st))
                                      ^
c_src/spawner.c:72:17: error: use of undeclared identifier 'u_char'
/usr/include/sys/socket.h:554:34: note: expanded from macro 'CMSG_DATA'
#define CMSG_DATA(cmsg) (__CASTV(u_char *, cmsg) + __CMSG_ASIZE)
                                 ^
2 errors generated.
```
>How-To-Repeat:
$ git clone https://github.com/akash-akya/exile
$ git checkout 71a21be
$ clang -Wall -Werror -Wno-unused-parameter -pedantic -std=c99 -O2 -D_POSIX_C_SOURCE=200809L c_src/spawner.c -o priv/spawner
>Fix:

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57871 CVS commit: src/sys/sys
Date: Mon, 22 Jan 2024 13:50:46 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Mon Jan 22 18:50:46 UTC 2024

 Modified Files:
 	src/sys/sys: socket.h

 Log Message:
 PR/57871: Haelwenn Monnier: Don't use u_char because it is not defined in with
 POSIX_C_SOURCE


 To generate a diff of this commit:
 cvs rdiff -u -r1.131 -r1.132 src/sys/sys/socket.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: jkoshy@NetBSD.org
State-Changed-When: Sat, 03 Feb 2024 18:46:22 +0000
State-Changed-Why:
Fix committed in r1.132 of src/sys/sys/socket.h.


From: "Haelwenn (lanodan) Monnier" <netbsd.org@hacktivis.me>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/57871 (CMSG_DATA uses u_char which is undefined when
 POSIX_C_SOURCE is set)
Date: Sun, 4 Feb 2024 01:45:29 +0100

 >State-Changed-From-To: open->feedback

 Should be good, I applied the patch on my test system as verification.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.