Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C program that uses splint and flags as many errors as possible from the

ID: 3839909 • Letter: W

Question

Write a C program that uses splint and flags as many errors as possible from the list of all the errors shown below: Dereferencing a possibly null pointer; Using possibly undefined storage or returning storage that is not properly defined; Type mismatches, with greater precision and flexibility than provided by C compilers; Violations of information hiding; Memory management errors including uses of dangling references and memory leaks; Dangerous aliasing; Modifications and global variable uses that are inconsistent with specified interfaces; Problematic control flow such as likely infinite loops, fall through eases or incomplete switches, and suspicious statements; Buffer overflow vulnerabilities; Dangerous macro implementations or invocations and Violations of customized naming conventions. In the program that you have written in the Problem#2, either correct the errors where ever possible or use appropriate annotations to circumvent the errors displayed by Splint.

Explanation / Answer

I will try to provide examples for some of the errors:

Undefined Variables:

And here it is the output of Splint:

Memory Management:

Here is the Splint output for the file above:

Here is an example of stack-allocated storage:

And here is the Splint output:

Control Flow

In order to avoid certain errors, Splint have to understand the control flow of the program, so Splint do some checks related to control flow. Many of these checks are possible because of the extra information that is known in annotations. Without this additional information Splint assumes that all functions return and execution continues normally.

noreturn annotation is used to denote a function that never returns.

We also have maynoreturn and alwaysreturns annotations, but Splint must assume that a function returns normally when checking the code and doesn’t verify if a function really returns.

To describe non-returning functions the noreturnwhentrue and noreturnwhenfalse mean that a function never returns if the first argument is true or false.

The sef annotation denotes a parameter as side effect free, and the alt int indicate that it may be either a Boolean or an integer.

Undefined Behavior

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote