Skip to content

This repository contains simple, categorized C programs that demonstrate the use of Splint annotations for static code analysis and annotations will help Splint catch common C programming bugs.

Notifications You must be signed in to change notification settings

Or4cle404/Annotations-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Splint Annotation Examples in C

This repository contains simple and practical C code examples demonstrating the use of Splint (Secure Programming Lint) annotations. Splint is a static code analysis tool that helps detect common programming mistakes in C, especially those related to pointer usage, memory management, and contract-based programming.


What is Splint?

Splint is a tool for statically checking C programs for security vulnerabilities and coding mistakes. It extends the standard C syntax with special annotations (written as comments) that describe properties of functions, pointers, and variables.


Annotations Covered

Annotation Purpose
/*@null@*/ Pointer may be null
/*@notnull@*/ Pointer must not be null
/*@in@*/ Input-only parameter
/*@out@*/ Output-only parameter
/*@temp@*/ Temporary pointer
/*@only@*/ Caller owns the memory; must free it
/*@returned@*/ Returned pointer is same as input
/*@requires@*/ Precondition before function call
/*@ensures@*/ Postcondition after execution

How to Use

  1. Install Splint (if not already installed):

    sudo apt install splint
  2. Compile normally

    gcc filename.c -o filename
    ./filename
  3. Run Splint to analyze the code

    splint filename.c

About

This repository contains simple, categorized C programs that demonstrate the use of Splint annotations for static code analysis and annotations will help Splint catch common C programming bugs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages