svn commit: r359978 - in head: lib/libc/gen lib/libc/net lib/libc/rpc sys/dev/ocs_fc sys/net80211

Brooks Davis brooks at FreeBSD.org
Wed Apr 15 18:16:00 UTC 2020


Author: brooks
Date: Wed Apr 15 18:15:58 2020
New Revision: 359978
URL: https://svnweb.freebsd.org/changeset/base/359978

Log:
  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)
  MFC after:	1 week
  Sponsored by:	DARPA
  Differential Revision:	https://reviews.freebsd.org/D24425

Modified:
  head/lib/libc/gen/getgrent.c
  head/lib/libc/gen/getpwent.c
  head/lib/libc/net/gethostnamadr.c
  head/lib/libc/net/getnetnamadr.c
  head/lib/libc/net/getprotoent.c
  head/lib/libc/net/getservent.c
  head/lib/libc/rpc/getrpcent.c
  head/sys/dev/ocs_fc/ocs_device.c
  head/sys/net80211/ieee80211_output.c

Modified: head/lib/libc/gen/getgrent.c
==============================================================================
--- head/lib/libc/gen/getgrent.c	Wed Apr 15 17:11:44 2020	(r359977)
+++ head/lib/libc/gen/getgrent.c	Wed Apr 15 18:15:58 2020	(r359978)
@@ -166,7 +166,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 *);
@@ -220,7 +220,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;
@@ -315,7 +315,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)
@@ -841,7 +841,7 @@ files_group(void *retval, void *mdata, va_list ap)
 	fresh = 0;
 	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 *);
@@ -1094,7 +1094,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 *);
@@ -1253,7 +1253,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)
@@ -1322,7 +1322,7 @@ compat_group(void *retval, void *mdata, va_list ap)
 	fresh = 0;
 	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: head/lib/libc/gen/getpwent.c
==============================================================================
--- head/lib/libc/gen/getpwent.c	Wed Apr 15 17:11:44 2020	(r359977)
+++ head/lib/libc/gen/getpwent.c	Wed Apr 15 18:15:58 2020	(r359978)
@@ -213,7 +213,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 *);
@@ -267,7 +267,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;
@@ -370,7 +370,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;
@@ -764,7 +764,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;
@@ -802,7 +802,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 *);
@@ -1294,7 +1294,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 *);
@@ -1693,7 +1693,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;
@@ -1740,7 +1740,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: head/lib/libc/net/gethostnamadr.c
==============================================================================
--- head/lib/libc/net/gethostnamadr.c	Wed Apr 15 17:11:44 2020	(r359977)
+++ head/lib/libc/net/gethostnamadr.c	Wed Apr 15 18:15:58 2020	(r359978)
@@ -177,7 +177,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 *);
@@ -268,7 +268,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);
@@ -375,7 +375,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: head/lib/libc/net/getnetnamadr.c
==============================================================================
--- head/lib/libc/net/getnetnamadr.c	Wed Apr 15 17:11:44 2020	(r359977)
+++ head/lib/libc/net/getnetnamadr.c	Wed Apr 15 18:15:58 2020	(r359978)
@@ -70,7 +70,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 *);
@@ -133,7 +133,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;
@@ -221,7 +221,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: head/lib/libc/net/getprotoent.c
==============================================================================
--- head/lib/libc/net/getprotoent.c	Wed Apr 15 17:11:44 2020	(r359977)
+++ head/lib/libc/net/getprotoent.c	Wed Apr 15 18:15:58 2020	(r359978)
@@ -97,7 +97,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 *);
@@ -155,7 +155,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;
@@ -241,7 +241,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: head/lib/libc/net/getservent.c
==============================================================================
--- head/lib/libc/net/getservent.c	Wed Apr 15 17:11:44 2020	(r359977)
+++ head/lib/libc/net/getservent.c	Wed Apr 15 18:15:58 2020	(r359978)
@@ -446,7 +446,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)
@@ -509,7 +509,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 *);
@@ -626,7 +626,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;
@@ -682,7 +682,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 *);
@@ -814,7 +814,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);
@@ -850,7 +850,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,
@@ -879,7 +879,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 *);
@@ -961,7 +961,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 *);
@@ -1058,7 +1058,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: head/lib/libc/rpc/getrpcent.c
==============================================================================
--- head/lib/libc/rpc/getrpcent.c	Wed Apr 15 17:11:44 2020	(r359977)
+++ head/lib/libc/rpc/getrpcent.c	Wed Apr 15 18:15:58 2020	(r359978)
@@ -227,7 +227,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:
@@ -347,7 +347,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);
@@ -407,7 +407,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:
@@ -584,7 +584,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:
@@ -611,7 +611,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 *);
@@ -668,7 +668,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;
@@ -754,7 +754,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: head/sys/dev/ocs_fc/ocs_device.c
==============================================================================
--- head/sys/dev/ocs_fc/ocs_device.c	Wed Apr 15 17:11:44 2020	(r359977)
+++ head/sys/dev/ocs_fc/ocs_device.c	Wed Apr 15 18:15:58 2020	(r359978)
@@ -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: head/sys/net80211/ieee80211_output.c
==============================================================================
--- head/sys/net80211/ieee80211_output.c	Wed Apr 15 17:11:44 2020	(r359977)
+++ head/sys/net80211/ieee80211_output.c	Wed Apr 15 18:15:58 2020	(r359978)
@@ -3247,7 +3247,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


More information about the svn-src-head mailing list