473,503 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1756
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
7070
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
2828
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
3042
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
1438
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
1941
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
4152
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
2735
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
3233
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
2083
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
3249
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
7203
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
7334
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...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5579
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,...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.