changeset 19450:18b15b55b7ae

12276 smatch-clean sockfs Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Jason King <jason.king@joyent.com> Approved by: Gordon Ross <gordon.w.ross@gmail.com>
author Dan McDonald <danmcd@joyent.com>
date Fri, 31 Jan 2020 15:04:37 -0500
parents 4d1e8d230570
children 6ea7b3377f82
files usr/src/uts/common/fs/sockfs/nl7curi.c usr/src/uts/common/fs/sockfs/sockfilter.c usr/src/uts/common/fs/sockfs/socktpi.c usr/src/uts/intel/sockfs/Makefile usr/src/uts/sparc/sockfs/Makefile
diffstat 5 files changed, 17 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/fs/sockfs/nl7curi.c	Mon Mar 05 20:41:49 2018 -0800
+++ b/usr/src/uts/common/fs/sockfs/nl7curi.c	Fri Jan 31 15:04:37 2020 -0500
@@ -1140,10 +1140,6 @@
 
 	alloc = kmem_alloc(sz, KM_SLEEP);
 	URI_RD_ADD(uri, rdp, sz, -1);
-	if (rdp == NULL) {
-		error = ENOMEM;
-		goto fail;
-	}
 
 	if (uri->hash != URI_TEMP && uri->count > nca_max_cache_size) {
 		uri_delete(uri);
@@ -1376,10 +1372,6 @@
 			fp = NULL;
 		}
 		URI_RD_ADD(uri, rdp, cnt, -1);
-		if (rdp == NULL) {
-			error = ENOMEM;
-			goto fail;
-		}
 		data = alloc;
 		alloc = NULL;
 		rdp->data.kmem = data;
@@ -1405,10 +1397,6 @@
 			if (len > cnt) {
 				/* More file data so add it */
 				URI_RD_ADD(uri, rdp, len - cnt, off);
-				if (rdp == NULL) {
-					error = ENOMEM;
-					goto fail;
-				}
 				rdp->data.vnode = vp;
 
 				/* Send vnode data out the connection */
--- a/usr/src/uts/common/fs/sockfs/sockfilter.c	Mon Mar 05 20:41:49 2018 -0800
+++ b/usr/src/uts/common/fs/sockfs/sockfilter.c	Fri Jan 31 15:04:37 2020 -0500
@@ -84,13 +84,13 @@
  *           sof_module_list -> sof_module_t -> ... -> sof_module_t
  */
 
-static list_t 	sof_entry_list;		/* list of configured filters */
+static list_t	sof_entry_list;		/* list of configured filters */
 
 static list_t	sof_module_list;	/* list of loaded filter modules */
 static kmutex_t	sof_module_lock;	/* protect the module list */
 
 static sof_kstat_t	sof_stat;
-static kstat_t 		*sof_stat_ksp;
+static kstat_t		*sof_stat_ksp;
 
 #ifdef DEBUG
 static int socket_filter_debug = 0;
@@ -116,15 +116,15 @@
 static void	sof_close_deferred(void *);
 
 static void		sof_module_rele(sof_module_t *);
-static sof_module_t 	*sof_module_hold_by_name(const char *, const char *);
+static sof_module_t	*sof_module_hold_by_name(const char *, const char *);
 
 static int		sof_entry_load_module(sof_entry_t *);
-static void 		sof_entry_hold(sof_entry_t *);
-static void 		sof_entry_rele(sof_entry_t *);
-static int 		sof_entry_kstat_create(sof_entry_t *);
-static void 		sof_entry_kstat_destroy(sof_entry_t *);
+static void		sof_entry_hold(sof_entry_t *);
+static void		sof_entry_rele(sof_entry_t *);
+static int		sof_entry_kstat_create(sof_entry_t *);
+static void		sof_entry_kstat_destroy(sof_entry_t *);
 
-static sof_instance_t 	*sof_instance_create(sof_entry_t *, struct sonode *);
+static sof_instance_t	*sof_instance_create(sof_entry_t *, struct sonode *);
 static void		sof_instance_destroy(sof_instance_t *);
 
 static int
@@ -1080,9 +1080,10 @@
 			    fil != NULL;
 			    fil = list_next(&sp->sp_auto_filters, fil)) {
 				if (strncmp(ent->sofe_hintarg,
-				    fil->spf_filter->sofe_name,
-				    SOF_MAXNAMELEN) == 0)
-				break;
+				    fil->spf_filter->sofe_name, SOF_MAXNAMELEN)
+				    == 0) {
+					break;
+				}
 			}
 
 			if (fil != NULL) {
--- a/usr/src/uts/common/fs/sockfs/socktpi.c	Mon Mar 05 20:41:49 2018 -0800
+++ b/usr/src/uts/common/fs/sockfs/socktpi.c	Fri Jan 31 15:04:37 2020 -0500
@@ -4811,8 +4811,8 @@
 		if (auditing)
 			audit_sock(T_UNITDATA_REQ, strvp2wq(SOTOV(so)), mp, 0);
 
-		udp_wput(udp_wq, mp);
-		return (0);
+		/* Always returns 0... */
+		return (udp_wput(udp_wq, mp));
 	}
 
 	ASSERT(mpdata == NULL);
@@ -4874,8 +4874,8 @@
 			}
 			mp = newmp;
 		}
-		tcp_wput(tcp_wq, mp);
-		return (0);
+		/* Always returns 0... */
+		return (tcp_wput(tcp_wq, mp));
 	}
 
 	/* Fallback to strwrite() to do proper error handling */
@@ -4925,7 +4925,7 @@
 			}
 			mp = newmp;
 		}
-		tcp_wput(tcp_wq, mp);
+		(void) tcp_wput(tcp_wq, mp);	/* Always returns 0 anyway. */
 
 		wflag |= NOINTR;
 
--- a/usr/src/uts/intel/sockfs/Makefile	Mon Mar 05 20:41:49 2018 -0800
+++ b/usr/src/uts/intel/sockfs/Makefile	Fri Jan 31 15:04:37 2020 -0500
@@ -43,7 +43,6 @@
 #
 MODULE		= sockfs
 OBJECTS		= $(SOCK_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(SOCK_OBJS:%.o=$(LINTS_DIR)/%.ln)
 ROOTMODULE	= $(ROOT_FS_DIR)/$(MODULE)
 
 #
@@ -55,7 +54,6 @@
 #	Define targets
 #
 ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
 INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
 
 #
@@ -73,19 +71,6 @@
 TOKGEN		 = $(SRCDIR)/nl7ctokgen
 DERIVED_FILES	 = nl7ctokgen.h
 CFLAGS		+= -I.
-LINTFLAGS	+= -I.
-
-#
-# For now, disable these lint checks; maintainers should endeavor
-# to investigate and remove these for maximum lint coverage.
-# Please do not carry these forward to new Makefiles.
-#
-LINTTAGS	+= -erroff=E_SUSPICIOUS_COMPARISON
-LINTTAGS	+= -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
-LINTTAGS	+= -erroff=E_STATIC_UNUSED
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-LINTTAGS	+= -erroff=E_PTRDIFF_OVERFLOW
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
 
 CERRWARN	+= -_gcc=-Wno-unused-label
 CERRWARN	+= -_gcc=-Wno-unused-value
@@ -94,9 +79,6 @@
 CERRWARN	+= -_gcc=-Wno-parentheses
 CERRWARN	+= $(CNOWARN_UNINIT)
 
-# needs work
-SMATCH=off
-
 #
 #	Default build targets.
 #
@@ -112,12 +94,6 @@
 clobber:	$(CLOBBER_DEPS)
 		$(RM) $(DERIVED_FILES)
 
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
 install:	$(INSTALL_DEPS)
 
 #
--- a/usr/src/uts/sparc/sockfs/Makefile	Mon Mar 05 20:41:49 2018 -0800
+++ b/usr/src/uts/sparc/sockfs/Makefile	Fri Jan 31 15:04:37 2020 -0500
@@ -42,7 +42,6 @@
 #
 MODULE		= sockfs
 OBJECTS		= $(SOCK_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(SOCK_OBJS:%.o=$(LINTS_DIR)/%.ln)
 ROOTMODULE	= $(ROOT_FS_DIR)/$(MODULE)
 
 #
@@ -54,7 +53,6 @@
 #	Define targets
 #
 ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
 INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
 
 #
@@ -73,19 +71,6 @@
 TOKGEN		 = $(SRCDIR)/nl7ctokgen
 DERIVED_FILES	 = nl7ctokgen.h
 CFLAGS		+= -I.
-LINTFLAGS	+= -I.
-
-#
-# For now, disable these lint checks; maintainers should endeavor
-# to investigate and remove these for maximum lint coverage.
-# Please do not carry these forward to new Makefiles.
-#
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-LINTTAGS	+= -erroff=E_PTRDIFF_OVERFLOW
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-LINTTAGS	+= -erroff=E_STATIC_UNUSED
-LINTTAGS	+= -erroff=E_SUSPICIOUS_COMPARISON
-LINTTAGS	+= -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
 
 CERRWARN	+= -_gcc=-Wno-unused-label
 CERRWARN	+= -_gcc=-Wno-unused-value
@@ -109,12 +94,6 @@
 clobber:	$(CLOBBER_DEPS)
 		$(RM) $(DERIVED_FILES)
 
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
 install:	$(INSTALL_DEPS)
 
 #