Skip to content

Commit

Permalink
11462 enable smatch by default
Browse files Browse the repository at this point in the history
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Dan McDonald <danmcd@joyent.com>
  • Loading branch information
John Levon committed Jul 18, 2019
1 parent 621caad commit 7ae7577
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
4 changes: 3 additions & 1 deletion usr/src/Makefile.smatch
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# Copyright (c) 2019, Joyent, Inc.
# Copyright 2019 Joyent, Inc.
#

#
Expand All @@ -27,6 +27,8 @@ SMATCH_ARGS += -Wno-external-function-has-definition
# we have lots of legacy "void foo();" in headers
SMATCH_ARGS += -Wno-old-style-definition
SMATCH_ARGS += -Wno-strict-prototypes
SMATCH_ARGS += --fatal-checks
SMATCH_ARGS += --timeout=120

CERRWARN += $(SMATCH_ARGS:%=-_smatch=%)

Expand Down
4 changes: 2 additions & 2 deletions usr/src/tools/env/illumos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export PRIMARY_CCCS=gcc7,$GNUC_ROOT/bin/g++,gnu
export SHADOW_CCS=gcc4,/opt/gcc/4.4.4/bin/gcc,gnu
export SHADOW_CCCS=gcc4,/opt/gcc/4.4.4/bin/g++,gnu

# uncomment to enable smatch
#export ENABLE_SMATCH=1
# comment to disable smatch
export ENABLE_SMATCH=1

# Comment this out to disable support for SMB printing, i.e. if you
# don't want to bother providing the CUPS headers this needs.
Expand Down
4 changes: 2 additions & 2 deletions usr/src/tools/smatch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

#
# The src/ sub-directory is un-modified copy of
# https://github.com/illumos/smatch/tree/0.5.1-il-1
# https://github.com/illumos/smatch/tree/0.5.1-il-3
#
# This Makefile installs just enough for us to be able to run smatch
# locally.
#

PROG = smatch
SPARSE_VERSION = 0.5.1-il-1
SPARSE_VERSION = 0.5.1-il-3

include ../Makefile.tools

Expand Down
11 changes: 10 additions & 1 deletion usr/src/tools/smatch/src/smatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
*
* Copyright 2019 Joyent, Inc.
*/

#include <stdio.h>
Expand Down Expand Up @@ -43,6 +45,7 @@ int option_mem;
char *option_datadir_str;
int option_fatal_checks;
int option_succeed;
int option_timeout = 60;

FILE *sm_outfd;
FILE *sql_outfd;
Expand Down Expand Up @@ -173,7 +176,7 @@ static int match_option(const char *arg, const char *option)
}

#define OPTION(_x) do { \
if (match_option((*argvp)[1], #_x)) { \
if (match_option((*argvp)[i], #_x)) { \
option_##_x = 1; \
} \
} while (0)
Expand Down Expand Up @@ -218,6 +221,12 @@ void parse_args(int *argcp, char ***argvp)
option_disable = 1;
}

if (!strncmp((*argvp)[i], "--timeout=", 10)) {
if (sscanf((*argvp)[i] + 10, "%d",
&option_timeout) != 1)
sm_fatal("invalid option %s", (*argvp)[i]);
}

OPTION(fatal_checks);
OPTION(spammy);
OPTION(info);
Expand Down
3 changes: 3 additions & 0 deletions usr/src/tools/smatch/src/smatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
*
* Copyright 2019 Joyent, Inc.
*/

#ifndef SMATCH_H_
Expand Down Expand Up @@ -200,6 +202,7 @@ extern int option_debug;
extern int local_debug;
extern int option_info;
extern int option_spammy;
extern int option_timeout;
extern char *trace_variable;
extern struct stree *global_states;
int is_skipped_function(void);
Expand Down
6 changes: 4 additions & 2 deletions usr/src/tools/smatch/src/smatch_implied.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
*
* Copyright 2019 Joyent, Inc.
*/

/*
Expand Down Expand Up @@ -397,7 +399,7 @@ static int taking_too_long(void)
if (out_of_memory())
return 1;

if (time_parsing_function() < 60)
if (time_parsing_function() < option_timeout)
return 0;

if (!__inline_fn && printed != cur_func_sym) {
Expand Down Expand Up @@ -593,7 +595,7 @@ static void separate_and_filter(struct sm_state *sm, int comparison, struct rang

gettimeofday(&time_after, NULL);
sec = time_after.tv_sec - time_before.tv_sec;
if (sec > 20) {
if (sec > option_timeout) {
sm->nr_children = 4000;
sm_perror("Function too hairy. Ignoring implications after %d seconds.", sec);
}
Expand Down

0 comments on commit 7ae7577

Please sign in to comment.