aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib.c
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-05-25 15:51:35 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-06-15 10:03:49 +0200
commitbcfe020ed939fa1e8474efaf31a86d80d0e5c5fe (patch)
treebf64a743ac1bc930757ac0198df845f544a13202 /lib.c
parent6081052837c130ef4875a993a8034c9520e4c0ef (diff)
downloadsparse-dev-bcfe020ed939fa1e8474efaf31a86d80d0e5c5fe.tar.gz
add support for -fmemcpy-max-count
By default, sparse will warn if memcpy() (or memset(), copy_from_user(), copy_to_user()) is called with a very large static byte-count. But the limit is currently fixed at 100000, which may be fine for some uses but not for others. For example, this value is too low for sparse to be used on the git tree where, for example, some array used to sort the index is cleared with memset(). Change this by making the limit configurable via a new flag: -fmemcpy-max-count. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 8bee1bfd..eac84ee3 100644
--- a/lib.c
+++ b/lib.c
@@ -257,6 +257,7 @@ int dbg_dead = 0;
int fmem_report = 0;
int fdump_linearize;
+unsigned long long fmemcpy_max_count = 100000;
int preprocess_only;
@@ -671,6 +672,21 @@ static char **handle_switch_O(char *arg, char **next)
return next;
}
+static char **handle_switch_fmemcpy_max_count(char *arg, char **next)
+{
+ unsigned long long val;
+ char *end;
+
+ val = strtoull(arg, &end, 0);
+ if (*end != '\0' || end == arg)
+ die("error: missing argument to \"-fmemcpy-max-count=\"");
+
+ if (val == 0)
+ val = ~0ULL;
+ fmemcpy_max_count = val;
+ return next;
+}
+
static char **handle_switch_ftabstop(char *arg, char **next)
{
char *end;
@@ -714,6 +730,8 @@ static char **handle_switch_f(char *arg, char **next)
return handle_switch_ftabstop(arg+8, next);
if (!strncmp(arg, "dump-", 5))
return handle_switch_fdump(arg+5, next);
+ if (!strncmp(arg, "memcpy-max-count=", 17))
+ return handle_switch_fmemcpy_max_count(arg+17, next);
/* handle switches w/ arguments above, boolean and only boolean below */
if (handle_simple_switch(arg, "mem-report", &fmem_report))