From 98b591d2e5f6ba3b43a8e990d43e90b75272d3fd Mon Sep 17 00:00:00 2001 From: drl7x Date: Tue, 22 Jan 2002 22:21:40 +0000 Subject: [PATCH 1/1] Added test cases for stringliteral initalization checking --- test/Makefile | 21 ++++++++++++++++++++- test/Makefile.am | 10 +++++++++- test/Makefile.in | 21 ++++++++++++++++++++- test/null6.lcd | 2 +- test/stringliteral.c | 8 ++++++++ test/stringliteral.expect | 22 ++++++++++++++++++++++ test/tests2.5/newlint.lcd | 2 +- 7 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 test/stringliteral.c create mode 100644 test/stringliteral.expect diff --git a/test/Makefile b/test/Makefile index 4009f0c..001119e 100644 --- a/test/Makefile +++ b/test/Makefile @@ -61,18 +61,29 @@ host_alias = host_triplet = i686-pc-linux-gnu target_alias = target_triplet = i686-pc-linux-gnu +AMTAR = ${SHELL} /net/af9/drl7x/reTmp/LCLintDev/config/missing --run tar +AWK = gawk BISON = bison CAT = cat CC = gcc CP = cp CPP = gcc -E +DEPDIR = .deps DIFF = diff +EXEEXT = GREP = grep +INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s LCLOBJ = $(lcl_OBJECTS) LEX = flex LN_S = ln -s MV = mv +OBJEXT = o +PACKAGE = splint RM = rm +VERSION = 3.0.1.4 +am__include = include +am__quote = +install_sh = /net/af9/drl7x/reTmp/LCLintDev/config/install-sh AUTOMAKE_OPTIONS = 1.5 foreign @@ -114,6 +125,7 @@ UNITTESTS = \ returned sharing shifts slovaknames \ specclauses \ special stack staticarray strings \ + stringliteral \ structassign typequals ud ulstypes union unioninit unreachable unsignedcompare \ unused ullint utypes void widestrings @@ -760,7 +772,9 @@ EXTRA_DIST = ./abst_t.lcl ./abst_t.lcs \ functionmacro.expect functionmacro.c info.c info.expect \ loopexec.c mergenull.c shifts.c \ manual.expect ./manual/Makefile \ - ./manual/annotglobs.c ./manual/bool.c ./manual/bool.h ./manual/clauses.c ./manual/employee.h ./manual/exposure.c ./manual/globals.c ./manual/ignore.c ./manual/implicit.c ./manual/intSet.h ./manual/list.c ./manual/loop.c ./manual/macros.c ./manual/modify.c ./manual/mstring.c ./manual/mstring.h ./manual/mstringnn.c ./manual/multiError.c ./manual/names.c ./manual/noeffect.c ./manual/null.c ./manual/only.c ./manual/order.c ./manual/palindrome.c ./manual/palindrome.h ./manual/refs.c ./manual/returned.c ./manual/rgb.c ./manual/rstring.c ./manual/rstring.h ./manual/sample.c ./manual/setChar.c ./manual/setname.c ./manual/setname.h ./manual/special.c ./manual/stack.c ./manual/sumsquares.c ./manual/switch.c ./manual/testpal.c ./manual/types.c ./manual/unique.c ./manual/usedef.c ./manual/bounds.c + ./manual/annotglobs.c ./manual/bool.c ./manual/bool.h ./manual/clauses.c ./manual/employee.h ./manual/exposure.c ./manual/globals.c ./manual/ignore.c ./manual/implicit.c ./manual/intSet.h ./manual/list.c ./manual/loop.c ./manual/macros.c ./manual/modify.c ./manual/mstring.c ./manual/mstring.h ./manual/mstringnn.c ./manual/multiError.c ./manual/names.c ./manual/noeffect.c ./manual/null.c ./manual/only.c ./manual/order.c ./manual/palindrome.c ./manual/palindrome.h ./manual/refs.c ./manual/returned.c ./manual/rgb.c ./manual/rstring.c ./manual/rstring.h ./manual/sample.c ./manual/setChar.c ./manual/setname.c ./manual/setname.h ./manual/special.c ./manual/stack.c ./manual/sumsquares.c ./manual/switch.c ./manual/testpal.c ./manual/types.c ./manual/unique.c ./manual/usedef.c ./manual/bounds.c \ + arraydims.expect arraydims.c \ + stringliteral.expect stringliteral.c subdir = test mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs @@ -1523,6 +1537,11 @@ stack: staticarray: -$(SPLINTR) staticarray.c -expect 3 +.PHONY: stringliteral +stringliteral: + -$(SPLINTR) stringliteral.c +stringliteralnoroomfinalnull -expect 4 + -$(SPLINTR) stringliteral.c -expect 3 + .PHONY: strings strings: -$(SPLINTR) strings.c -expect 3 diff --git a/test/Makefile.am b/test/Makefile.am index 05e68a0..469dd71 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -48,6 +48,7 @@ UNITTESTS = \ returned sharing shifts slovaknames \ specclauses \ special stack staticarray strings \ + stringliteral \ structassign typequals ud ulstypes union unioninit unreachable unsignedcompare \ unused ullint utypes void widestrings UNITEXPECTS = $(addsuffix .expect, $(UNITTESTS)) @@ -726,6 +727,11 @@ stack: staticarray: -$(SPLINTR) staticarray.c -expect 3 +.PHONY: stringliteral +stringliteral: + -$(SPLINTR) stringliteral.c +stringliteralnoroomfinalnull -expect 4 + -$(SPLINTR) stringliteral.c -expect 3 + .PHONY: strings strings: -$(SPLINTR) strings.c -expect 3 @@ -1482,4 +1488,6 @@ EXTRA_DIST = ./abst_t.lcl ./abst_t.lcs \ functionmacro.expect functionmacro.c info.c info.expect \ loopexec.c mergenull.c shifts.c \ manual.expect ./manual/Makefile \ - ./manual/annotglobs.c ./manual/bool.c ./manual/bool.h ./manual/clauses.c ./manual/employee.h ./manual/exposure.c ./manual/globals.c ./manual/ignore.c ./manual/implicit.c ./manual/intSet.h ./manual/list.c ./manual/loop.c ./manual/macros.c ./manual/modify.c ./manual/mstring.c ./manual/mstring.h ./manual/mstringnn.c ./manual/multiError.c ./manual/names.c ./manual/noeffect.c ./manual/null.c ./manual/only.c ./manual/order.c ./manual/palindrome.c ./manual/palindrome.h ./manual/refs.c ./manual/returned.c ./manual/rgb.c ./manual/rstring.c ./manual/rstring.h ./manual/sample.c ./manual/setChar.c ./manual/setname.c ./manual/setname.h ./manual/special.c ./manual/stack.c ./manual/sumsquares.c ./manual/switch.c ./manual/testpal.c ./manual/types.c ./manual/unique.c ./manual/usedef.c ./manual/bounds.c + ./manual/annotglobs.c ./manual/bool.c ./manual/bool.h ./manual/clauses.c ./manual/employee.h ./manual/exposure.c ./manual/globals.c ./manual/ignore.c ./manual/implicit.c ./manual/intSet.h ./manual/list.c ./manual/loop.c ./manual/macros.c ./manual/modify.c ./manual/mstring.c ./manual/mstring.h ./manual/mstringnn.c ./manual/multiError.c ./manual/names.c ./manual/noeffect.c ./manual/null.c ./manual/only.c ./manual/order.c ./manual/palindrome.c ./manual/palindrome.h ./manual/refs.c ./manual/returned.c ./manual/rgb.c ./manual/rstring.c ./manual/rstring.h ./manual/sample.c ./manual/setChar.c ./manual/setname.c ./manual/setname.h ./manual/special.c ./manual/stack.c ./manual/sumsquares.c ./manual/switch.c ./manual/testpal.c ./manual/types.c ./manual/unique.c ./manual/usedef.c ./manual/bounds.c \ + arraydims.expect arraydims.c \ + stringliteral.expect stringliteral.c diff --git a/test/Makefile.in b/test/Makefile.in index a668c2d..6f80010 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -61,18 +61,29 @@ host_alias = @host_alias@ host_triplet = @host@ target_alias = @target_alias@ target_triplet = @target@ +AMTAR = @AMTAR@ +AWK = @AWK@ BISON = @BISON@ CAT = @CAT@ CC = @CC@ CP = @CP@ CPP = @CPP@ +DEPDIR = @DEPDIR@ DIFF = @DIFF@ +EXEEXT = @EXEEXT@ GREP = @GREP@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LCLOBJ = @LCLOBJ@ LEX = @LEX@ LN_S = @LN_S@ MV = @MV@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ RM = @RM@ +VERSION = @VERSION@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ AUTOMAKE_OPTIONS = 1.5 foreign @@ -114,6 +125,7 @@ UNITTESTS = \ returned sharing shifts slovaknames \ specclauses \ special stack staticarray strings \ + stringliteral \ structassign typequals ud ulstypes union unioninit unreachable unsignedcompare \ unused ullint utypes void widestrings @@ -760,7 +772,9 @@ EXTRA_DIST = ./abst_t.lcl ./abst_t.lcs \ functionmacro.expect functionmacro.c info.c info.expect \ loopexec.c mergenull.c shifts.c \ manual.expect ./manual/Makefile \ - ./manual/annotglobs.c ./manual/bool.c ./manual/bool.h ./manual/clauses.c ./manual/employee.h ./manual/exposure.c ./manual/globals.c ./manual/ignore.c ./manual/implicit.c ./manual/intSet.h ./manual/list.c ./manual/loop.c ./manual/macros.c ./manual/modify.c ./manual/mstring.c ./manual/mstring.h ./manual/mstringnn.c ./manual/multiError.c ./manual/names.c ./manual/noeffect.c ./manual/null.c ./manual/only.c ./manual/order.c ./manual/palindrome.c ./manual/palindrome.h ./manual/refs.c ./manual/returned.c ./manual/rgb.c ./manual/rstring.c ./manual/rstring.h ./manual/sample.c ./manual/setChar.c ./manual/setname.c ./manual/setname.h ./manual/special.c ./manual/stack.c ./manual/sumsquares.c ./manual/switch.c ./manual/testpal.c ./manual/types.c ./manual/unique.c ./manual/usedef.c ./manual/bounds.c + ./manual/annotglobs.c ./manual/bool.c ./manual/bool.h ./manual/clauses.c ./manual/employee.h ./manual/exposure.c ./manual/globals.c ./manual/ignore.c ./manual/implicit.c ./manual/intSet.h ./manual/list.c ./manual/loop.c ./manual/macros.c ./manual/modify.c ./manual/mstring.c ./manual/mstring.h ./manual/mstringnn.c ./manual/multiError.c ./manual/names.c ./manual/noeffect.c ./manual/null.c ./manual/only.c ./manual/order.c ./manual/palindrome.c ./manual/palindrome.h ./manual/refs.c ./manual/returned.c ./manual/rgb.c ./manual/rstring.c ./manual/rstring.h ./manual/sample.c ./manual/setChar.c ./manual/setname.c ./manual/setname.h ./manual/special.c ./manual/stack.c ./manual/sumsquares.c ./manual/switch.c ./manual/testpal.c ./manual/types.c ./manual/unique.c ./manual/usedef.c ./manual/bounds.c \ + arraydims.expect arraydims.c \ + stringliteral.expect stringliteral.c subdir = test mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs @@ -1523,6 +1537,11 @@ stack: staticarray: -$(SPLINTR) staticarray.c -expect 3 +.PHONY: stringliteral +stringliteral: + -$(SPLINTR) stringliteral.c +stringliteralnoroomfinalnull -expect 4 + -$(SPLINTR) stringliteral.c -expect 3 + .PHONY: strings strings: -$(SPLINTR) strings.c -expect 3 diff --git a/test/null6.lcd b/test/null6.lcd index 903e888..cb73b87 100644 --- a/test/null6.lcd +++ b/test/null6.lcd @@ -1,5 +1,5 @@ ;;; Splint Library null6.lcd -;;Splint 3.0.1.4 --- 18 Jan 2002 +;;Splint 3.0.1.4 --- 19 Jan 2002 ;;lib:298 ;;ctTable 0 u-2 19 38 diff --git a/test/stringliteral.c b/test/stringliteral.c new file mode 100644 index 0000000..723ed92 --- /dev/null +++ b/test/stringliteral.c @@ -0,0 +1,8 @@ + +char buf[8] = "\000\000\000\000\000\000\000\000"; +char bufa[8] = "\000\000\000\000\000\000\000\001"; +char buf2[4] = "abcd"; +char buf3[4] = "ab\n"; +char buf4[4] = "\034\342\24"; +char buf5[4] = "abcdef"; + diff --git a/test/stringliteral.expect b/test/stringliteral.expect new file mode 100644 index 0000000..729b128 --- /dev/null +++ b/test/stringliteral.expect @@ -0,0 +1,22 @@ + +stringliteral.c:2:15: String literal with 9 characters is assigned to char [8] + (no room for final null terminator): "\000\000\000\000\000\000\000\000" +stringliteral.c:3:16: String literal with 9 characters is assigned to char [8] + (no room for null terminator): "\000\000\000\000\000\000\000\001" +stringliteral.c:4:16: String literal with 5 characters is assigned to char [4] + (no room for null terminator): "abcd" +stringliteral.c:7:16: String literal with 7 characters (counting null + terminator) is assigned to char [4] (insufficient storage available): + "abcdef" + +Finished checking --- 4 code warnings, as expected + +stringliteral.c:3:16: String literal with 9 characters is assigned to char [8] + (no room for null terminator): "\000\000\000\000\000\000\000\001" +stringliteral.c:4:16: String literal with 5 characters is assigned to char [4] + (no room for null terminator): "abcd" +stringliteral.c:7:16: String literal with 7 characters (counting null + terminator) is assigned to char [4] (insufficient storage available): + "abcdef" + +Finished checking --- 3 code warnings, as expected diff --git a/test/tests2.5/newlint.lcd b/test/tests2.5/newlint.lcd index b2bb6ef..0a47c79 100644 --- a/test/tests2.5/newlint.lcd +++ b/test/tests2.5/newlint.lcd @@ -1,5 +1,5 @@ ;;; Splint Library newlint.lcd -;;Splint 3.0.1.4 --- 18 Jan 2002 +;;Splint 3.0.1.4 --- 19 Jan 2002 ;;lib:298 ;;ctTable 0 u-2 19 38 -- 2.45.2