473,396 Members | 1,671 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,396 software developers and data experts.

"Implicitly only" splint warnings

When running the following code through splint, I get two warnings that
I don't fully understand.

This is the code :

---
typedef struct
{
int *pData;
} t_MyStruct;

static t_MyStruct myStruct =
{
(void *)0
};

static int myData = 0;

void process(void)
{
myStruct.pData = &myData;
}
---

And here are the warnings :

---
Splint 3.1.1 --- 12 April 2003

< loading standard library C:\Programme\splint-3.1.1\lib\standard.lcd
..... >
< preprocessing >
< checking test.c >
test.c: (in function process)
test.c(16,3): Implicitly only storage myStruct.pData (type int *) not
released
before assignment: myStruct.pData = &myData
A memory leak has been detected. Only-qualified storage is not
released
before the last reference to it is lost. (Use -mustfreeonly to
inhibit
warning)
test.c(16,3): Immediate address &myData assigned to implicitly only:
myStruct.pData = &myData
An immediate address (result of & operator) is transferred
inconsistently.
(Use -immediatetrans to inhibit warning)
< global checks >

Finished checking --- 2 code warnings
---

Anyone knows what's wrong with my code ?
Thanks for your help,
Guy.

Nov 14 '05 #1
2 5152
Guy Eschemann wrote:
When running the following code through splint, I get two warnings that
I don't fully understand.

This is the code :

---
typedef struct
{
int *pData;
} t_MyStruct;

static t_MyStruct myStruct =
{
(void *)0 splint will warn you about this, as well if you do not give
/*@null@*/ comments. };

static int myData = 0;

void process(void)
{
myStruct.pData = &myData;
Well, why is this ugly?

1. You may lose the only pointer to the storage pData is pointing
to. In this case, this does not happen, as myStruct.pData is a null
pointer at first and afterwards, you will not do anything -- but you
do not control it.
2. splint seems to think that you would be better of if making a copy.
}
---

And here are the warnings :

---
Splint 3.1.1 --- 12 April 2003

< loading standard library C:\Programme\splint-3.1.1\lib\standard.lcd
.... >
< preprocessing >
< checking test.c >
test.c: (in function process)
test.c(16,3): Implicitly only storage myStruct.pData (type int *) not
released
before assignment: myStruct.pData = &myData
A memory leak has been detected. Only-qualified storage is not
released
before the last reference to it is lost. (Use -mustfreeonly to
inhibit
warning)
test.c(16,3): Immediate address &myData assigned to implicitly only:
myStruct.pData = &myData
An immediate address (result of & operator) is transferred
inconsistently.
(Use -immediatetrans to inhibit warning)
< global checks >

Finished checking --- 2 code warnings
---

Anyone knows what's wrong with my code ?


Your "problems" stem from the "only" qualification splint assumes;
IIRC, splint has a huge manual where you hopefully can find a way
that the member pData is not /*@only@*/.

IMO, only 1. is a real problem. I would use assert(myStruct.pData==NULL)
to make sure that there is nothing to be overwritten if process() is
called only once. Otherwise, you would have to make sure that pData
is not the only pointer to allocated storage.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 14 '05 #2
Thanks a lot, that was very helpful !
Guy.

Nov 14 '05 #3

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

Similar topics

0
by: Arne Kösling | last post by:
Hi ! I am new to Web Services. Therefore I ve set up a PHP Installation on Windows (PHP 4.3.2 and Apache 1.3.29). I have tested PHP alone and then installed PEAR. Now I am stuck there (Before...
1
by: Fie Fie Niles | last post by:
I have IIS installed on XP Professional workstation machine. I have an ASP page that open connection to an Access database, then when trying to update the database, it gave me the error "cannot...
0
by: Bennett Haselton | last post by:
I'm trying to port my MySQL tables for a database called "tracerlock" from one server to another. On the old server, in the /var/lib/mysql/tracerlock directory, there was a ".MYD", ".MYI" and...
3
by: Vic | last post by:
Dear All, I have a database of laboratory records in Access 2000. There is one form which acts as an interface to input experimetal data. This form incorporates information from several tables....
0
by: Adi Doron | last post by:
Dear Sir,Madam: How can i open multicast channel for: a) Sending Only b) Reciving Only Best Regards to all =================== Adi
267
by: Xah Lee | last post by:
Python, Lambda, and Guido van Rossum Xah Lee, 2006-05-05 In this post, i'd like to deconstruct one of Guido's recent blog about lambda in Python. In Guido's blog written in 2006-02-10 at...
206
by: WaterWalk | last post by:
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a...
2
by: kirk | last post by:
I'd like to programmatically be able to determine if a network interface is currently in "Local Only" or "Local and Internet" access mode. Also I wasn't sure if this is only applicable to Windows...
3
by: Rahul Babbar | last post by:
Hi, I had the following doubts about the "For Read Only" clause. 1. How does a "for Read only" clause improve the performance? 2. How does a "for Read only" clause compare with "With UR"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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.