Template:Refimprove

{{#invoke:Infobox|infobox}}Template:Template other{{#invoke:Check for unknown parameters | check | showblankpositional=1 | unknown = Template:Main other | preview = Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y | AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo upright | logo size | logo title | logo_alt | logo_caption | logo_upright | logo_size | logo_title | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot upright | screenshot size | screenshot title | screenshot_alt | screenshot_upright | screenshot_size | screenshot_title | service_name | size | standard | title | ver layout | website | qid }}Template:Main other

Splint, short for Secure Programming Lint, is a programming tool for statically checking C programs for security vulnerabilities and coding mistakes. Formerly called LCLint, it is a modern version of the Unix lint tool.

Splint has the ability to interpret special annotations to the source code, which gives it stronger checking than is possible just by looking at the source alone. Splint is used by gpsd as part of an effort to design for zero defects.<ref>Template:Cite book</ref>

Splint is free software released under the terms of the GNU General Public License.

Main development activity on Splint stopped in 2010. According to the CVS at SourceForge, as of September 2012 the most recent change in the repository was in November 2010.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> A Git repository at GitHub has more recent changes, starting in July 2019.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

ExampleEdit

<syntaxhighlight lang="c">

  1. include <stdio.h>

int main() {

   char c;
   while (c != 'x');
   {
       c = getchar();
       if (c = 'x')
           return 0;
       switch (c) {
       case '\n':
       case '\r':
           printf("Newline\n");
       default:
           printf("%c",c);
       }
   }
   return 0;

} </syntaxhighlight>

Splint's output:

Variable c used before definition
Suspected infinite loop. No value used in loop test (c) is modified by test or loop body.
Assignment of int to char: c = getchar()
Test expression for if is assignment expression: c = 'x'
Test expression for if not boolean, type char: c = 'x'
Fall through case (no preceding break)

Fixed source: <syntaxhighlight lang="c">

  1. include <stdio.h>

int main() {

   int c = 0;  // Added an initial assignment definition.
   while (c != 'x') {
       c = getchar();  // Corrected type of c to int
       if (c == 'x') // Fixed the assignment error to make it a comparison operator.
           return 0;
       switch (c) {
       case '\n':
       case '\r':
           printf("Newline\n");
           break;  // Added break statement to prevent fall-through.
       default:
           printf("%c",c);
           break;  //Added break statement to default catch, out of good practice.
       }
   }
   return 0;

} </syntaxhighlight>

See alsoEdit

Template:Portal

ReferencesEdit

Template:Reflist

External linksEdit


Template:Programming-software-stub