summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjbj <jbj>2002-07-02 23:54:38 +0000
committerjbj <jbj>2002-07-02 23:54:38 +0000
commit60d1a9abc0d3cdd45d3bd98f11db7ec5f1aa211a (patch)
tree8ad45d01da7d9a49bc97e3409af59cb518b07334
parent67b64b7205108ee9b1ea84f337b6cbd820eb19f8 (diff)
downloadlibpopt-60d1a9abc0d3cdd45d3bd98f11db7ec5f1aa211a.tar.gz
Add boundsread annotations throughout, enable +bounds checking.
Start narrowing the scope of bounds annotations by adding more annotations.
-rw-r--r--.lclintrc3
-rw-r--r--popt.c2
-rw-r--r--popthelp.c4
-rw-r--r--test1.c2
4 files changed, 9 insertions, 2 deletions
diff --git a/.lclintrc b/.lclintrc
index a3d22bc..49aac97 100644
--- a/.lclintrc
+++ b/.lclintrc
@@ -13,8 +13,7 @@
+strict # lclint level
# --- in progress
-#+bounds # 56
-+boundswrite # 40
++bounds
# --- +partial artifacts
-exportlocal # 14
diff --git a/popt.c b/popt.c
index e4d6d31..d2dffa7 100644
--- a/popt.c
+++ b/popt.c
@@ -335,8 +335,10 @@ static int handleAlias(/*@special@*/ poptContext con,
if ((con->os - con->optionStack + 1) == POPT_OPTION_DEPTH)
return POPT_ERROR_OPTSTOODEEP;
+/*@-boundsread@*/
if (nextCharArg && *nextCharArg)
con->os->nextCharArg = nextCharArg;
+/*@=boundsread@*/
con->os++;
con->os->next = 0;
diff --git a/popthelp.c b/popthelp.c
index 5f9d54f..801dca5 100644
--- a/popthelp.c
+++ b/popthelp.c
@@ -325,6 +325,7 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
}
helpLength = strlen(help);
+/*@-boundsread@*/
while (helpLength > lineLength) {
const char * ch;
char format[10];
@@ -343,6 +344,7 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
while (isspace(*help) && *help) help++;
helpLength = strlen(help);
}
+/*@=boundsread@*/
if (helpLength) fprintf(fp, "%s\n", help);
@@ -479,9 +481,11 @@ static int showHelpIntro(poptContext con, FILE * fp)
fprintf(fp, POPT_("Usage:"));
if (!(con->flags & POPT_CONTEXT_KEEP_FIRST)) {
+/*@-boundsread@*/
/*@-nullderef@*/ /* LCL: wazzup? */
fn = con->optionStack->argv[0];
/*@=nullderef@*/
+/*@=boundsread@*/
if (fn == NULL) return len;
if (strchr(fn, '/')) fn = strrchr(fn, '/') + 1;
fprintf(fp, " %s", fn);
diff --git a/test1.c b/test1.c
index d1bbc47..8d84144 100644
--- a/test1.c
+++ b/test1.c
@@ -254,6 +254,7 @@ int main(int argc, const char ** argv)
if (singleDash)
fprintf(stdout, " -");
+/*@-boundsread@*/
rest = poptGetArgs(optCon);
if (rest) {
fprintf(stdout, " rest:");
@@ -262,6 +263,7 @@ int main(int argc, const char ** argv)
rest++;
}
}
+/*@=boundsread@*/
fprintf(stdout, "\n");