NetBSD Problem Report #57871

From  Mon Jan 22 18:35:15 2024
Return-Path: <>
Received: from ( [])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "", Issuer " CA" (not verified))
	by (Postfix) with ESMTPS id 295B71A9238
	for <>; Mon, 22 Jan 2024 18:35:15 +0000 (UTC)
Message-Id: <>
Date: Mon, 22 Jan 2024 18:35:13 +0000 (UTC)
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
>Last-Modified:  Sun Feb 04 00:50:01 +0000 2024
>Originator:     Haelwenn (lanodan) Monnier
>Release:        9.3
NetBSD build 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug  4 15:30:37 UTC 2022 amd64

As seen in (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.
$ git clone
$ 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


From: "Christos Zoulas" <>
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

 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-When: Sat, 03 Feb 2024 18:46:22 +0000
Fix committed in r1.132 of src/sys/sys/socket.h.

From: "Haelwenn (lanodan) Monnier" <>
Subject: Re: lib/57871 (CMSG_DATA uses u_char which is undefined when
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.


NetBSD Home
NetBSD PR Database Search

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