Skip to content

Commit

Permalink
10703 smatch unreachable code checking needs reworking
Browse files Browse the repository at this point in the history
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Approved by: Dan McDonald <danmcd@joyent.com>
  • Loading branch information
John Levon committed Aug 21, 2019
1 parent a99cb96 commit 44bf619
Show file tree
Hide file tree
Showing 48 changed files with 110 additions and 177 deletions.
2 changes: 1 addition & 1 deletion usr/src/Makefile.smatch
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# simply too much legacy).
#

SMATCH_ARGS = --disable=uninitialized,check_check_deref,unreachable
SMATCH_ARGS = --disable=uninitialized,check_check_deref

# VLAs are OK by us
SMATCH_ARGS += -Wno-vla
Expand Down
4 changes: 2 additions & 2 deletions usr/src/cmd/ctfmerge/ctfmerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

/*
* Copyright (c) 2019, Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*/

/*
Expand Down Expand Up @@ -47,7 +47,7 @@ static uint_t g_nctf;
#define CTFMERGE_DEFAULT_NTHREADS 8
#define CTFMERGE_ALTEXEC "CTFMERGE_ALTEXEC"

static void
static void __attribute__((__noreturn__))
ctfmerge_fatal(const char *fmt, ...)
{
va_list ap;
Expand Down
6 changes: 5 additions & 1 deletion usr/src/cmd/cxgbetool/cxgbetool.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
* Copyright (c) 2018 by Chelsio Communications, Inc.
*/

/*
* Copyright 2019 Joyent, Inc.
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Expand Down Expand Up @@ -85,7 +89,7 @@ static void usage(FILE *fp)
exit(fp == stderr ? 1 : 0);
}

static void
__NORETURN static void
err(int code, const char *fmt, ...)
{
va_list ap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/

/*
* Copyright 2019 Joyent, Inc.
*/

#include <sys/types.h>
#include <strings.h>
#include <fm/fmd_api.h>
Expand Down Expand Up @@ -112,7 +116,6 @@ fmevt_init_outbound(fmd_hdl_t *hdl)
EVCH_CREAT | EVCH_HOLD_PEND_INDEF) != 0) {
fmd_hdl_abort(hdl, "Unable to bind channel %s",
channel_name);
return;
}

channel_depth = fmd_prop_get_int32(hdl, "outbound_channel_depth");
Expand Down
8 changes: 2 additions & 6 deletions usr/src/cmd/fs.d/reparsed/reparsed.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

/*
* Copyright (c) 2018, Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*/

/*
Expand Down Expand Up @@ -187,7 +187,7 @@ main(int argc, char *argv[])
return (start_reparsed_svcs());
}

static void
__NORETURN static void
reparsed_door_call_error(int error, int buflen)
{
reparsed_door_res_t rpd_res;
Expand Down Expand Up @@ -354,10 +354,6 @@ start_reparsed_svcs()
/*
* Wait for incoming calls
*/
/*CONSTCOND*/
while (1)
(void) pause();

syslog(LOG_ERR, "Door server exited");
return (10);
}
3 changes: 1 addition & 2 deletions usr/src/cmd/mdb/common/mdb/mdb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

/*
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright 2019 Joyent, Inc.
*/

#include <sys/types.h>
Expand Down Expand Up @@ -1098,7 +1098,6 @@ main(int argc, char *argv[], char *envp[])
terminate((status == MDB_ERR_QUIT || status == 0) ?
(eflag != NULL && mdb.m_lastret != 0 ? 1 : 0) : 1);
/*NOTREACHED*/
return (0);

reexec:
if ((p = strrchr(execname, '/')) == NULL)
Expand Down
5 changes: 4 additions & 1 deletion usr/src/cmd/od/od.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
* Copyright 2010 Nexenta Systems, Inc. All rights reserved.
*/

/*
* Copyright 2019 Joyent, Inc.
*/

/*
* od - octal dump. Not really just octal anymore; read the POSIX
* specification for it -- its more complex than you think!
Expand Down Expand Up @@ -533,7 +537,6 @@ do_type_string(char *typestr)
default:
errx(1, _("unrecognized type string character: %c"),
*typestr);
exit(1);
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions usr/src/cmd/sgs/libld/common/map_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* All Rights Reserved
*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*
* Copyright 2019 Joyent, Inc.
*/

/*
Expand Down Expand Up @@ -2073,10 +2075,6 @@ ld_map_gettoken(Mapfile *mf, int flags, ld_map_tkval_t *tkv)
return (tok);
}
}

/*NOTREACHED*/
assert(0);
return (TK_ERROR);
}

/*
Expand Down
6 changes: 2 additions & 4 deletions usr/src/cmd/sgs/libld/common/map_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/

/*
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright 2019 Joyent, Inc.
*/

/*
Expand Down Expand Up @@ -84,8 +84,6 @@ ld_map_kwfind(const char *name, void *array, size_t name_offset,
}

/*NOTREACHED*/
assert(0);
return (NULL);
}
#endif

Expand Down Expand Up @@ -199,7 +197,7 @@ ld_map_cap_set_ovflag(Mapfile *mf, Word type)
* override flag.
*/
static ofl_flag_t override_flag[CA_SUNW_NUM] = {
0, /* CA_SUNW_NULL */
0, /* CA_SUNW_NULL */
FLG_OF1_OVHWCAP1, /* CA_SUNW_HW_1 */
FLG_OF1_OVSFCAP1, /* CA_SUNW_SF_1 */
FLG_OF1_OVHWCAP2, /* CA_SUNW_HW_2 */
Expand Down
8 changes: 4 additions & 4 deletions usr/src/cmd/sgs/libld/common/map_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
* Use is subject to license terms.
*/

/*
* Copyright 2019 Joyent, Inc.
*/

/*
* Map file parsing, Version 2 syntax (solaris).
*/
Expand Down Expand Up @@ -3318,8 +3322,4 @@ ld_map_parse_v2(Mapfile *mf)
return (FALSE);
}
}

/*NOTREACHED*/
assert(0);
return (FALSE);
}
2 changes: 1 addition & 1 deletion usr/src/cmd/svc/configd/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2015 RackTop Systems.
* Copyright 2019 Joyent, Inc.
*/

/*
Expand Down Expand Up @@ -1988,7 +1989,6 @@ start_audit_session(repcache_client_t *cp)
case EFAULT:
default:
bad_error("door_ucred", errno);
return;
}
}
if (adt_start_session(&session, NULL, 0) != 0) {
Expand Down
19 changes: 1 addition & 18 deletions usr/src/cmd/svc/startd/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2018 Joyent, Inc.
* Copyright 2019 Joyent, Inc.
* Copyright (c) 2015, Syneto S.R.L. All rights reserved.
* Copyright 2016 Toomas Soome <tsoome@me.com>
* Copyright 2016 RackTop Systems.
Expand Down Expand Up @@ -5817,14 +5817,6 @@ graph_event_thread(void *unused)

MUTEX_UNLOCK(&gu->gu_lock);
}

/*
* Unreachable for now -- there's currently no graceful cleanup
* called on exit().
*/
MUTEX_UNLOCK(&gu->gu_lock);
scf_handle_destroy(h);
return (NULL);
}

static void
Expand Down Expand Up @@ -6190,15 +6182,6 @@ graph_thread(void *arg)
(void) pthread_cond_wait(&gu->gu_freeze_cv,
&gu->gu_freeze_lock);
}

/*
* Unreachable for now -- there's currently no graceful cleanup
* called on exit().
*/
(void) pthread_mutex_unlock(&gu->gu_freeze_lock);
scf_handle_destroy(h);

return (NULL);
}


Expand Down
10 changes: 1 addition & 9 deletions usr/src/cmd/svc/startd/restarter.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2018 Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*/

/*
Expand Down Expand Up @@ -2090,14 +2090,6 @@ restarter_event_thread(void *unused)
MUTEX_LOCK(&ru->restarter_update_lock);
}
}

/*
* Unreachable for now -- there's currently no graceful cleanup
* called on exit().
*/
(void) scf_handle_unbind(h);
scf_handle_destroy(h);
return (NULL);
}

static restarter_inst_t *
Expand Down
4 changes: 1 addition & 3 deletions usr/src/cmd/svc/svcprop/svcprop.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

/*
* Copyright (c) 2011, Joyent, Inc. All rights reserved.
* Copyright 2019 Joyent, Inc.
*/

/*
Expand Down Expand Up @@ -630,8 +630,6 @@ process_pg(scf_propertygroup_t *pg)
"has too many components for property "
"group `%s'.\n"), spn->spn_comp1, spn->spn_comp2,
buf);

free(buf);
}

if (scf_pg_get_property(pg, spn->spn_comp1, prop) == 0) {
Expand Down
11 changes: 6 additions & 5 deletions usr/src/cmd/ul/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,26 @@
# CDDL HEADER END
#
#
#ident "%Z%%M% %I% %E% SMI"
#
# Copyright (c) 1989 by Sun Microsystems, Inc.
#
# Copyright 2019 Joyent, Inc.
#

PROG= ul

include ../Makefile.cmd

LDLIBS += -lcurses

# false positive
SMOFF += unreachable

.KEEP_STATE:

all: $(PROG)
all: $(PROG)

install: all $(ROOTPROG)

clean:

lint: lint_PROG

include ../Makefile.targ
6 changes: 5 additions & 1 deletion usr/src/cmd/zonecfg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# Copyright (c) 2018, Joyent, Inc.
# Copyright 2019 Joyent, Inc.
#

PROG= zonecfg
OBJS= zonecfg.o zonecfg_lex.o zonecfg_grammar.tab.o
Expand All @@ -49,6 +50,9 @@ CERRWARN += -_gcc=-Wno-implicit-function-declaration

SMOFF += all_func_returns

# false positive
zonecfg_lex.o := SMOFF += free

CLOBBERFILES += $(PROG).ln

.KEEP_STATE:
Expand Down
7 changes: 4 additions & 3 deletions usr/src/lib/brand/shared/brand/Makefile.com
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#
# Copyright 2013 Nexenta Systems, Inc. All rights reserved.
#
# Copyright (c) 2019, Joyent, Inc.
# Copyright 2019 Joyent, Inc.
#

COBJS = brand_util.o
Expand Down Expand Up @@ -55,6 +55,9 @@ CPPFLAGS += -D_REENTRANT -U_ASM -I. -I../sys
CFLAGS += $(CCVERBOSE)
ASFLAGS = -P $(ASFLAGS_$(CURTYPE)) -D_ASM -I. -I../sys

# intentional code after abort()
SMOFF += unreachable

.KEEP_STATE:

#
Expand All @@ -67,8 +70,6 @@ ASFLAGS = -P $(ASFLAGS_$(CURTYPE)) -D_ASM -I. -I../sys
#
all: pics .WAIT $$(PICS)

lint: lintcheck

$(OBJECTS:%=pics/%): $(OFFSETS_H)

$(OFFSETS_H): $(OFFSETS_SRC)
Expand Down
Loading

0 comments on commit 44bf619

Please sign in to comment.