ignore.c:10: Return value (type bool) ignored: fb()
Finished checking --- 1 code warning, as expected
+
+setChar.c:5: Possible out-of-bounds store:
+ buf[10]
+ Unable to resolve constraint:
+ requires 9 >= 10
+ needed to satisfy precondition:
+ requires maxSet(buf @ setChar.c:5) >= 10
+
+Finished checking --- 1 code warning, as expected
+
+multiError.c:4: Possible out-of-bounds store:
+ buf[2]
+ Unable to resolve constraint:
+ requires maxSet(buf @ multiError.c:4) >= 2
+ needed to satisfy precondition:
+ requires maxSet(buf @ multiError.c:4) >= 2
+
+Finished checking --- 1 code warning, as expected
+
+updateMyEnv.c:16: Possible out-of-bounds store:
+ strcpy(str, tmp)
+ Unable to resolve constraint:
+ requires maxSet(str @ updateMyEnv.c:16) >=
+ maxRead(getenv("MYENV") @ updateMyEnv.c:14)
+ needed to satisfy precondition:
+ requires maxSet(str @ updateMyEnv.c:16) >=
+ maxRead(tmp @ updateMyEnv.c:16)
+ derived from strcpy precondition: requires
+ maxSet(<parameter 1>) >= maxRead(<parameter 2>)
+
+Finished checking --- 1 code warning, as expected
+
+Finished checking --- no warnings
all: sample null mstring usedef bool palindrome only stack rstring unique \
exposure modify globals annotglobs clauses order loop switch noeffect \
- ignore
+ ignore setChar multiError updateMyEnv updateMyEnvGood
### In line example
.PHONY: sample
$(SPLINT) $(SPLINTFLAGS) bool.h ignore.c -retvalint -expect 1
### Figure 23:
-.PHONY: names
+.PHONY: Anames
names: names.c
$(SPLINT) $(SPLINTFLAGS) names.c +distinctinternalnames +internalnamelookalike +isoreserved -expect 3
+### Figure ???:
+
+.PHONY: setChar
+setChar: setChar.c
+ $(SPLINT) $(SPLINTFLAGS) setChar.c +arraybounds +arrayboundsread -exportlocal +constraintlocation -expect 1
+
+
+.PHONY: multiError
+multiError: multiError.c
+ $(SPLINT) $(SPLINTFLAGS) multiError.c +arraybounds +arrayboundsread -exportlocal +constraintlocation -expect 1
+
+
+.PHONY: updateMyEnv
+updateMyEnv: updateMyEnv.c
+ $(SPLINT) $(SPLINTFLAGS) updateMyEnv.c +arraybounds +arrayboundsread -exportlocal +constraintlocation -expect 1
+
+
+.PHONY: updateMyEnvGood
+updateMyEnvGood: updateMyEnvGood.c
+ $(SPLINT) $(SPLINTFLAGS) updateMyEnvGood.c +arraybounds +arrayboundsread -exportlocal +constraintlocation -expect 0
+
clean:
-rm -f core a.out *.*~
--- /dev/null
+#include<string.h>
+#include<stdlib.h>
+
+
+void updateMyEnv2(char * str) /*@requires maxSet(str) >= 1000@*/
+{
+ char * tmp;
+ tmp = getenv("MYENV");
+ if (tmp != NULL)
+ {
+ strncpy (str, tmp, 999);
+ str[999] = '/0';
+ }
+}
+
+void updateMyEnv3(char * str, size_t strSize) /*@requires maxSet(str) >= (strSize -1)@*/
+{
+ char * tmp;
+ tmp = getenv("MYENV");
+ if (tmp != NULL)
+ {
+ strncpy (str, tmp, strSize -1);
+ str[strSize -1] = '/0';
+ }
+}