473,569 Members | 2,698 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 1769
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*@securescie nce.net> wrote in message news:<ka******* *********@news0 4.bloor.is.net. cable.rogers.co m>...
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
7118
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 (microsoft.com, cnn.com, etc.) at the W3 Validator; to my surprise none of them passed. Doesn't anyone care anymore, or are the standards more-or-less...
5
2832
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 suppress the file to only display one topic at a time. It then uses bookmarks to jump around the file. I realize that this could be done with...
22
3044
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 so easy. Everything in the code either goes right to machine code, or links to a C library (often libc) or links to the kernel. Are there libc...
3
1443
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 --> foo (using linker ld)
2
1946
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
4159
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 initializing the DirectoryEntry object. For example sake our domain name is mydomain.net so the LDAP path I use is LDAP://DC=mydomain,DC=Net...
3
2741
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 phpinfo, the "mysql api client is ver. 4.0.25" - I have no idea how this relates, if at all, to the mysql engine's version. background:
48
3263
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 (and for someone who has loved Microsoft as much as me, that takes something pretty bad!). I am a web developer, and only have access to one...
2
2089
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 SetDlgItemText() when it displays a message on screen. If I kill this displaying message then the program continue to run and run fine. I know...
2
3259
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 compiled) the standard print dialog box will not appear. As far as I can tell, all other parts of my executable file, which include the opening of...
0
7698
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7673
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7970
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2113
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 we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.