From db8a5c0eb2d4b986b9505e4dfc3c6c72f39b2f13 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 6 Feb 2013 21:53:53 +0300 Subject: [PATCH] param_(filter|limit|set): add some comments Hopefully, this clarifies a little how these work together. Signed-off-by: Dan Carpenter --- smatch_param_filter.c | 14 ++++++++++++++ smatch_param_limit.c | 19 +++++++++++++++++++ smatch_param_set.c | 17 +++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/smatch_param_filter.c b/smatch_param_filter.c index d86d0cc5..192d29f9 100644 --- a/smatch_param_filter.c +++ b/smatch_param_filter.c @@ -7,6 +7,20 @@ * */ +/* + * This is for functions like: + * + * void foo(int *x) + * { + * if (*x == 42) + * *x = 0; + * } + * + * The final value of *x depends on the input to the function but with *x == 42 + * filtered out. + * + */ + #include "smatch.h" #include "smatch_extra.h" #include "smatch_slist.h" diff --git a/smatch_param_limit.c b/smatch_param_limit.c index 148a9b6b..62a49d11 100644 --- a/smatch_param_limit.c +++ b/smatch_param_limit.c @@ -7,6 +7,25 @@ * */ +/* + * This is for functions like this: + * + * int foo(int a) + * { + * if (a >= 0 && a < 10) { + * a = 42; + * return 1; + * } + * return 0; + * } + * + * If we pass in 5, it returns 1. + * + * It's a bit complicated because we can't just consider the final value, we + * have to always consider the passed in value. + * + */ + #include "scope.h" #include "smatch.h" #include "smatch_extra.h" diff --git a/smatch_param_set.c b/smatch_param_set.c index 7bbc8d5c..dd215eb0 100644 --- a/smatch_param_set.c +++ b/smatch_param_set.c @@ -7,6 +7,23 @@ * */ +/* + * This is for functions like: + * + * int foo(int *x) + * { + * if (*x == 42) { + * *x = 0; + * return 1; + * } + * return 0; + * } + * + * If we return 1 that means the value of *x has been set to 0. If we return + * 0 then we have left *x alone. + * + */ + #include "scope.h" #include "smatch.h" #include "smatch_slist.h" -- 2.11.4.GIT