Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Apr 2020 23:49:13 +0000 (UTC)
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r360415 - in stable/11: lib/libc/gen lib/libc/net lib/libc/rpc sys/dev/ocs_fc sys/net80211
Message-ID:  <202004272349.03RNnDKR076634@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brooks
Date: Mon Apr 27 23:49:13 2020
New Revision: 360415
URL: https://svnweb.freebsd.org/changeset/base/360415

Log:
  MFC r359978:
  
  Fix -Wvoid-pointer-to-enum-cast warnings.
  
  This pattern is used in callbacks with void * data arguments and seems
  both relatively uncommon and relatively harmless.  Silence the warning
  by casting through uintptr_t.
  
  This warning is on by default in Clang 11.
  
  Reviewed by:	arichardson
  Obtained from:	CheriBSD (partial)
  Sponsored by:	DARPA
  Differential Revision:	https://reviews.freebsd.org/D24425

Modified:
  stable/11/lib/libc/gen/getgrent.c
  stable/11/lib/libc/gen/getpwent.c
  stable/11/lib/libc/net/gethostnamadr.c
  stable/11/lib/libc/net/getnetnamadr.c
  stable/11/lib/libc/net/getprotoent.c
  stable/11/lib/libc/net/getservent.c
  stable/11/lib/libc/rpc/getrpcent.c
  stable/11/sys/dev/ocs_fc/ocs_device.c
  stable/11/sys/net80211/ieee80211_output.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/gen/getgrent.c
==============================================================================
--- stable/11/lib/libc/gen/getgrent.c	Mon Apr 27 23:47:40 2020	(r360414)
+++ stable/11/lib/libc/gen/getgrent.c	Mon Apr 27 23:49:13 2020	(r360415)
@@ -164,7 +164,7 @@ grp_id_func(char *buffer, size_t *buffer_size, va_list
 	enum nss_lookup_type lookup_type;
 
 
-	lookup_type = (enum nss_lookup_type)cache_mdata;
+	lookup_type = (enum nss_lookup_type)(uintptr_t)cache_mdata;
 	switch (lookup_type) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
@@ -218,7 +218,7 @@ grp_marshal_func(char *buffer, size_t *buffer_size, vo
 	size_t desired_size, size, mem_size;
 	char *p, **mem;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
 		break;
@@ -313,7 +313,7 @@ grp_unmarshal_func(char *buffer, size_t buffer_size, v
 	char *p;
 	char **mem;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
 		break;
@@ -804,7 +804,7 @@ files_setgrent(void *retval, void *mdata, va_list ap)
 	rv = files_getstate(&st);
 	if (rv != 0) 
 		return (NS_UNAVAIL);
-	switch ((enum constants)mdata) {
+	switch ((enum constants)(uintptr_t)mdata) {
 	case SETGRENT:
 		stayopen = va_arg(ap, int);
 		if (st->fp != NULL)
@@ -840,7 +840,7 @@ files_group(void *retval, void *mdata, va_list ap)
 
 	name = NULL;
 	gid = (gid_t)-1;
-	how = (enum nss_lookup_type)mdata;
+	how = (enum nss_lookup_type)(uintptr_t)mdata;
 	switch (how) {
 	case nss_lt_name:
 		name = va_arg(ap, const char *);
@@ -1087,7 +1087,7 @@ nis_group(void *retval, void *mdata, va_list ap)
 	
 	name = NULL;
 	gid = (gid_t)-1;
-	how = (enum nss_lookup_type)mdata;
+	how = (enum nss_lookup_type)(uintptr_t)mdata;
 	switch (how) {
 	case nss_lt_name:
 		name = va_arg(ap, const char *);
@@ -1246,7 +1246,7 @@ compat_setgrent(void *retval, void *mdata, va_list ap)
 	rv = compat_getstate(&st);
 	if (rv != 0)
 		return (NS_UNAVAIL);
-	switch ((enum constants)mdata) {
+	switch ((enum constants)(uintptr_t)mdata) {
 	case SETGRENT:
 		stayopen = va_arg(ap, int);
 		if (st->fp != NULL)
@@ -1314,7 +1314,7 @@ compat_group(void *retval, void *mdata, va_list ap)
 
 	name = NULL;
 	gid = (gid_t)-1;
-	how = (enum nss_lookup_type)mdata;
+	how = (enum nss_lookup_type)(uintptr_t)mdata;
 	switch (how) {
 	case nss_lt_name:
 		name = va_arg(ap, const char *);

Modified: stable/11/lib/libc/gen/getpwent.c
==============================================================================
--- stable/11/lib/libc/gen/getpwent.c	Mon Apr 27 23:47:40 2020	(r360414)
+++ stable/11/lib/libc/gen/getpwent.c	Mon Apr 27 23:49:13 2020	(r360415)
@@ -211,7 +211,7 @@ pwd_id_func(char *buffer, size_t *buffer_size, va_list
 	int	res = NS_UNAVAIL;
 	enum nss_lookup_type lookup_type;
 
-	lookup_type = (enum nss_lookup_type)cache_mdata;
+	lookup_type = (enum nss_lookup_type)(uintptr_t)cache_mdata;
 	switch (lookup_type) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
@@ -265,7 +265,7 @@ pwd_marshal_func(char *buffer, size_t *buffer_size, vo
 	size_t desired_size, size;
 	char *p;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
 		break;
@@ -368,7 +368,7 @@ pwd_unmarshal_func(char *buffer, size_t buffer_size, v
 
 	char *p;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
 		break;
@@ -762,7 +762,7 @@ files_setpwent(void *retval, void *mdata, va_list ap)
 	rv = files_getstate(&st);
 	if (rv != 0)
 		return (NS_UNAVAIL);
-	switch ((enum constants)mdata) {
+	switch ((enum constants)(uintptr_t)mdata) {
 	case SETPWENT:
 		stayopen = va_arg(ap, int);
 		st->keynum = 0;
@@ -800,7 +800,7 @@ files_passwd(void *retval, void *mdata, va_list ap)
 
 	name = NULL;
 	uid = (uid_t)-1;
-	how = (enum nss_lookup_type)mdata;
+	how = (enum nss_lookup_type)(uintptr_t)mdata;
 	switch (how) {
 	case nss_lt_name:
 		name = va_arg(ap, const char *);
@@ -1292,7 +1292,7 @@ nis_passwd(void *retval, void *mdata, va_list ap)
 
 	name = NULL;
 	uid = (uid_t)-1;
-	how = (enum nss_lookup_type)mdata;
+	how = (enum nss_lookup_type)(uintptr_t)mdata;
 	switch (how) {
 	case nss_lt_name:
 		name = va_arg(ap, const char *);
@@ -1691,7 +1691,7 @@ compat_setpwent(void *retval, void *mdata, va_list ap)
 	rv = compat_getstate(&st);
 	if (rv != 0)
 		return (NS_UNAVAIL);
-	switch ((enum constants)mdata) {
+	switch ((enum constants)(uintptr_t)mdata) {
 	case SETPWENT:
 		stayopen = va_arg(ap, int);
 		st->keynum = 0;
@@ -1738,7 +1738,7 @@ compat_passwd(void *retval, void *mdata, va_list ap)
 	from_compat = 0;
 	name = NULL;
 	uid = (uid_t)-1;
-	how = (enum nss_lookup_type)mdata;
+	how = (enum nss_lookup_type)(uintptr_t)mdata;
 	switch (how) {
 	case nss_lt_name:
 		name = va_arg(ap, const char *);

Modified: stable/11/lib/libc/net/gethostnamadr.c
==============================================================================
--- stable/11/lib/libc/net/gethostnamadr.c	Mon Apr 27 23:47:40 2020	(r360414)
+++ stable/11/lib/libc/net/gethostnamadr.c	Mon Apr 27 23:49:13 2020	(r360415)
@@ -175,7 +175,7 @@ host_id_func(char *buffer, size_t *buffer_size, va_lis
 	res_options = statp->options & (RES_RECURSE | RES_DEFNAMES |
 	    RES_DNSRCH | RES_NOALIASES | RES_USE_INET6);
 
-	lookup_type = (enum nss_lookup_type)cache_mdata;
+	lookup_type = (enum nss_lookup_type)(uintptr_t)cache_mdata;
 	switch (lookup_type) {
 	case nss_lt_name:
 		str = va_arg(ap, char *);
@@ -266,7 +266,7 @@ host_marshal_func(char *buffer, size_t *buffer_size, v
 	size_t desired_size, aliases_size, addr_size, size;
 	char *p, **iter;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		str = va_arg(ap, char *);
 		type = va_arg(ap, int);
@@ -373,7 +373,7 @@ host_unmarshal_func(char *buffer, size_t buffer_size, 
 	char *orig_buf;
 	size_t orig_buf_size;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		str = va_arg(ap, char *);
 		type = va_arg(ap, int);

Modified: stable/11/lib/libc/net/getnetnamadr.c
==============================================================================
--- stable/11/lib/libc/net/getnetnamadr.c	Mon Apr 27 23:47:40 2020	(r360414)
+++ stable/11/lib/libc/net/getnetnamadr.c	Mon Apr 27 23:49:13 2020	(r360415)
@@ -68,7 +68,7 @@ net_id_func(char *buffer, size_t *buffer_size, va_list
 	enum nss_lookup_type lookup_type;
 	int res = NS_UNAVAIL;
 
-	lookup_type = (enum nss_lookup_type)cache_mdata;
+	lookup_type = (enum nss_lookup_type)(uintptr_t)cache_mdata;
 	switch (lookup_type) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
@@ -131,7 +131,7 @@ net_marshal_func(char *buffer, size_t *buffer_size, vo
 	char *p;
 	char **alias;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
 		break;
@@ -219,7 +219,7 @@ net_unmarshal_func(char *buffer, size_t buffer_size, v
 	char *p;
 	char **alias;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
 		break;

Modified: stable/11/lib/libc/net/getprotoent.c
==============================================================================
--- stable/11/lib/libc/net/getprotoent.c	Mon Apr 27 23:47:40 2020	(r360414)
+++ stable/11/lib/libc/net/getprotoent.c	Mon Apr 27 23:49:13 2020	(r360415)
@@ -95,7 +95,7 @@ __proto_id_func(char *buffer, size_t *buffer_size, va_
 	enum nss_lookup_type lookup_type;
 	int res = NS_UNAVAIL;
 
-	lookup_type = (enum nss_lookup_type)cache_mdata;
+	lookup_type = (enum nss_lookup_type)(uintptr_t)cache_mdata;
 	switch (lookup_type) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
@@ -153,7 +153,7 @@ __proto_marshal_func(char *buffer, size_t *buffer_size
 	char *p;
 	char **alias;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
 		break;
@@ -239,7 +239,7 @@ __proto_unmarshal_func(char *buffer, size_t buffer_siz
 	char *p;
 	char **alias;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
 		break;

Modified: stable/11/lib/libc/net/getservent.c
==============================================================================
--- stable/11/lib/libc/net/getservent.c	Mon Apr 27 23:47:40 2020	(r360414)
+++ stable/11/lib/libc/net/getservent.c	Mon Apr 27 23:49:13 2020	(r360415)
@@ -444,7 +444,7 @@ files_setservent(void *retval, void *mdata, va_list ap
 	if (rv != 0)
 		return (NS_UNAVAIL);
 
-	switch ((enum constants)mdata) {
+	switch ((enum constants)(uintptr_t)mdata) {
 	case SETSERVENT:
 		f = va_arg(ap,int);
 		if (st->fp == NULL)
@@ -507,7 +507,7 @@ db_servent(void *retval, void *mdata, va_list ap)
 
 	name = NULL;
 	proto = NULL;
-	how = (enum nss_lookup_type)mdata;
+	how = (enum nss_lookup_type)(uintptr_t)mdata;
 	switch (how) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
@@ -624,7 +624,7 @@ db_setservent(void *retval, void *mdata, va_list ap)
 	if (rv != 0)
 		return (NS_UNAVAIL);
 
-	switch ((enum constants)mdata) {
+	switch ((enum constants)(uintptr_t)mdata) {
 	case SETSERVENT:
 		f = va_arg(ap, int);
 		st->stayopen |= f;
@@ -680,7 +680,7 @@ nis_servent(void *retval, void *mdata, va_list ap)
 	name = NULL;
 	proto = NULL;
 	buf = NULL;
-	how = (enum nss_lookup_type)mdata;
+	how = (enum nss_lookup_type)(uintptr_t)mdata;
 	switch (how) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
@@ -812,7 +812,7 @@ nis_setservent(void *result, void *mdata, va_list ap)
 	if (rv != 0)
 		return (NS_UNAVAIL);
 
-	switch ((enum constants)mdata) {
+	switch ((enum constants)(uintptr_t)mdata) {
 	case SETSERVENT:
 	case ENDSERVENT:
 		free(st->yp_key);
@@ -848,7 +848,7 @@ compat_setservent(void *retval, void *mdata, va_list a
 
 	(void)files_setservent(retval, mdata, ap);
 
-	switch ((enum constants)mdata) {
+	switch ((enum constants)(uintptr_t)mdata) {
 	case SETSERVENT:
 		f = va_arg(ap,int);
 		(void)nsdispatch(retval, compat_dtab, NSDB_SERVICES_COMPAT,
@@ -877,7 +877,7 @@ serv_id_func(char *buffer, size_t *buffer_size, va_lis
 	enum nss_lookup_type lookup_type;
 	int res = NS_UNAVAIL;
 
-	lookup_type = (enum nss_lookup_type)cache_mdata;
+	lookup_type = (enum nss_lookup_type)(uintptr_t)cache_mdata;
 	switch (lookup_type) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
@@ -959,7 +959,7 @@ serv_marshal_func(char *buffer, size_t *buffer_size, v
 	size_t size;
 	size_t aliases_size;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
 		proto = va_arg(ap, char *);
@@ -1056,7 +1056,7 @@ serv_unmarshal_func(char *buffer, size_t buffer_size, 
 	size_t orig_buf_size;
 	int *ret_errno;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
 		proto = va_arg(ap, char *);

Modified: stable/11/lib/libc/rpc/getrpcent.c
==============================================================================
--- stable/11/lib/libc/rpc/getrpcent.c	Mon Apr 27 23:47:40 2020	(r360414)
+++ stable/11/lib/libc/rpc/getrpcent.c	Mon Apr 27 23:49:13 2020	(r360415)
@@ -225,7 +225,7 @@ files_rpcent(void *retval, void *mdata, va_list ap)
 	int stayopen;
 	enum nss_lookup_type how;
 
-	how = (enum nss_lookup_type)mdata;
+	how = (enum nss_lookup_type)(uintptr_t)mdata;
 	switch (how)
 	{
 	case nss_lt_name:
@@ -345,7 +345,7 @@ files_setrpcent(void *retval, void *mdata, va_list ap)
 	if (rv != 0)
 		return (NS_UNAVAIL);
 
-	switch ((enum constants)mdata)
+	switch ((enum constants)(uintptr_t)mdata)
 	{
 	case SETRPCENT:
 		f = va_arg(ap,int);
@@ -405,7 +405,7 @@ nis_rpcent(void *retval, void *mdata, va_list ap)
 	enum nss_lookup_type	how;
 	int	no_name_active;
 
-	how = (enum nss_lookup_type)mdata;
+	how = (enum nss_lookup_type)(uintptr_t)mdata;
 	switch (how)
 	{
 	case nss_lt_name:
@@ -582,7 +582,7 @@ nis_setrpcent(void *retval, void *mdata, va_list ap)
 	if (rv != 0)
 		return (NS_UNAVAIL);
 
-	switch ((enum constants)mdata)
+	switch ((enum constants)(uintptr_t)mdata)
 	{
 	case SETRPCENT:
 	case ENDRPCENT:
@@ -609,7 +609,7 @@ rpc_id_func(char *buffer, size_t *buffer_size, va_list
 	enum nss_lookup_type lookup_type;
 	int res = NS_UNAVAIL;
 
-	lookup_type = (enum nss_lookup_type)cache_mdata;
+	lookup_type = (enum nss_lookup_type)(uintptr_t)cache_mdata;
 	switch (lookup_type) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
@@ -666,7 +666,7 @@ rpc_marshal_func(char *buffer, size_t *buffer_size, vo
 	char *p;
 	char **alias;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
 		break;
@@ -752,7 +752,7 @@ rpc_unmarshal_func(char *buffer, size_t buffer_size, v
 	char *p;
 	char **alias;
 
-	switch ((enum nss_lookup_type)cache_mdata) {
+	switch ((enum nss_lookup_type)(uintptr_t)cache_mdata) {
 	case nss_lt_name:
 		name = va_arg(ap, char *);
 		break;

Modified: stable/11/sys/dev/ocs_fc/ocs_device.c
==============================================================================
--- stable/11/sys/dev/ocs_fc/ocs_device.c	Mon Apr 27 23:47:40 2020	(r360414)
+++ stable/11/sys/dev/ocs_fc/ocs_device.c	Mon Apr 27 23:49:13 2020	(r360415)
@@ -1238,7 +1238,7 @@ __ocs_d_wait_topology_notify(ocs_sm_ctx_t *ctx, ocs_sm
 		break;
 
 	case OCS_EVT_SPORT_TOPOLOGY_NOTIFY: {
-		ocs_sport_topology_e topology = (ocs_sport_topology_e)arg;
+		ocs_sport_topology_e topology = (ocs_sport_topology_e)(uintptr_t)arg;
 		ocs_assert(!node->sport->domain->attached, NULL);
 		ocs_assert(node->send_ls_acc == OCS_NODE_SEND_LS_ACC_PLOGI, NULL);
 		node_printf(node, "topology notification, topology=%d\n", topology);

Modified: stable/11/sys/net80211/ieee80211_output.c
==============================================================================
--- stable/11/sys/net80211/ieee80211_output.c	Mon Apr 27 23:47:40 2020	(r360414)
+++ stable/11/sys/net80211/ieee80211_output.c	Mon Apr 27 23:49:13 2020	(r360415)
@@ -2874,7 +2874,7 @@ static void
 ieee80211_tx_mgt_cb(struct ieee80211_node *ni, void *arg, int status)
 {
 	struct ieee80211vap *vap = ni->ni_vap;
-	enum ieee80211_state ostate = (enum ieee80211_state) arg;
+	enum ieee80211_state ostate = (enum ieee80211_state)(uintptr_t)arg;
 
 	/*
 	 * Frame transmit completed; arrange timer callback.  If



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004272349.03RNnDKR076634>