473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Does pc-lint catch this type of problem?

I am new to lint and have been experimenting with splint. An
initialization problem I was caught on recently was not found by
splint. Would pc-lint catch this problem:

/* test program for splint */
/* body of func1 commented out to recreate lack of initialization */
static int x[3];
void func1( void);
int func2(void);
void func3(int *);

void func1( void)
{
/* when commented out,
x[0]= 0;
x[1]= 1;
x[2]= 2;
x[] is not initialized */
}

int func2(void)
{
int y;
func3(&x[0]);
y= x[0] + x[1] + x[2];
return y;
}

void func3(int * u)
{
/* some filter code */
u[2]= u[1];
u[1]= u[0];
}

Splint 3.1.1 --- 12 April 2003
Finished checking --- no warnings

Thanks,
Nov 14 '05 #1
2 1755
Brian wrote:
I am new to lint and have been experimenting with splint. An
initialization problem I was caught on recently was not found by
splint. Would pc-lint catch this problem:

/* test program for splint */
/* body of func1 commented out to recreate lack of initialization */
static int x[3];
x[] == {0, 0, 0}

It is initialized.

void func1( void);
int func2(void);
void func3(int *);

void func1( void)
{
/* when commented out,
x[0]= 0;
x[1]= 1;
x[2]= 2;
x[] is not initialized */
}

int func2(void)
{
int y;
func3(&x[0]);
You could write that as x instead of &x[0].
y= x[0] + x[1] + x[2];
This is valid because x[] == {0, 0, 0}
return y;
}

void func3(int * u)
{
/* some filter code */
u[2]= u[1];
u[1]= u[0];
}

Splint 3.1.1 --- 12 April 2003
Finished checking --- no warnings


The code is valid. Also from the point of view of just looking at the
functiosn blindly func3() is always valid (it doesn't use the globals).

Tom
Nov 14 '05 #2
Tom St Denis <to*@securescience.net> wrote in message news:<ka****************@news04.bloor.is.net.cable .rogers.com>...
Brian wrote:
I am new to lint and have been experimenting with splint. An
initialization problem I was caught on recently was not found by
splint. Would pc-lint catch this problem:

/* test program for splint */
/* body of func1 commented out to recreate lack of initialization */
static int x[3];


x[] == {0, 0, 0}

It is initialized.

void func1( void);
int func2(void);
void func3(int *);

void func1( void)
{
/* when commented out,
x[0]= 0;
x[1]= 1;
x[2]= 2;
x[] is not initialized */
}

int func2(void)
{
int y;
func3(&x[0]);


You could write that as x instead of &x[0].
y= x[0] + x[1] + x[2];


This is valid because x[] == {0, 0, 0}
return y;
}

void func3(int * u)
{
/* some filter code */
u[2]= u[1];
u[1]= u[0];
}

Splint 3.1.1 --- 12 April 2003
Finished checking --- no warnings


The code is valid. Also from the point of view of just looking at the
functiosn blindly func3() is always valid (it doesn't use the globals).

Tom


Ah! your right. I wonder why my embedded DSP code had garbage in x
until I explicitly initialized it. Maybe the boot loader isn't
initializing static data ?
In any case thanks for your help.
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

162
by: Isaac Grover | last post by:
Hi everyone, Just out of curiosity I recently pointed one of my hand-typed pages at the W3 Validator, and my hand-typed code was just ripped to shreds. Then I pointed some major sites...
5
by: SA Dev | last post by:
Hi, I just finished writing something to make a help file for a Pocket PC device. The Pocket PC device allows not really showing the .HTM file as a long single file, but instead uses a tag to...
22
by: Ryan M | last post by:
I've been programming for a while, but most of my experience is on unix. How do C compilers work on operating systems that weren't written in C? And that have no libc? Compiling C on unix seems...
3
by: Sorav Bansal | last post by:
Is there a way to print out all the operations performed in a gcc call: eg. gcc foo.c -o foo perhaps performs foo.c --> foo.s (using compiler) foo.s --> foo.o (using assembler as) foo.o...
2
by: | last post by:
I'm thinking of writing a a screensaver for any type of PC Will my application run in any PC or does .Net have minimum requirements on the PC that'll run the application? Thanks.
1
by: Brad | last post by:
I'm trying to use Active Directory to retrieve information for a user...for display purposes.. I am not using windows authentication or impersonation....I am using a fixed user id and password for...
3
by: nsh | last post by:
mailing.database.mysql, comp.lang.php subject: does "LOAD DATA" EVER work?!? I've tried EVERYTHING! version info: my isp is running my web page on a linux box with php ver. 4.4.1 according to...
48
by: Nathan Sokalski | last post by:
Ever since I found out that they didn't give us a way to install both IE6 and IE7 on the same machine, I have been more frustrated and annoyed with Microsoft than I ever have been with any company...
2
by: ttam | last post by:
Hi, I have a C++ program that runs fine on Windows 2000 for about 5 yrs now and PC is old, I want to replace this PC and Windows 2000 with a new PC and XP, but when I run this program, it hangs at...
2
by: EngineerCrom | last post by:
I am compiling C# code on a 64-bit PC using Windows XP x64 OS for "Any CPU". The compiled version opens the standard print dialog box fine, but on my 64-bit PC (the same PC on which the source was...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.