473,672 Members | 2,643 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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\sp lint-3.1.1\lib\stand ard.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 5175
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\sp lint-3.1.1\lib\stand ard.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
4404
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 that, I had many problems with the PHP-dlls) I've set up several SOAP Testscripts that I found on WebSites and in PHP-Books to get a PHP Client and a PHP Server communicate over Web Services (using PEAR::SOAP).
1
3954
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 update database or object is read-only". This is a workstation machine, not connected to any other computer, and I login to the PC using an administrator account. I already check the .MDB file is NOT read-only. But, I do not see the .LDB file....
0
2748
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 ".frm" file for every table in the database. So after creating a database called "tracerlock" on the new server, I copied these files over to the /var/lib/mysql/tracerlock directory on the new server. On both servers, all the table files are owned...
3
2572
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. I have a flag (yes/no field) indicating whether a particular experiment (one record) is completed (ie all data belonging to that record is inputted and quality controlled). What I want is that when I change the flag to "yes" the particular record...
0
1144
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
10693
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 http://www.artima.com/weblogs/viewpost.jsp?thread=147358
206
8302
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 footprint which says: "Indeed, one often hears arguments against building exibility into an engineered sys- tem. For example, in the philosophy of the computer language Python it is claimed: \There should be one|and preferably only one|obvious...
2
1786
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 Vista? If not possible in C#, maybe netsh can do it?
3
13243
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" clause in performance? Which is faster? Can someone clarify on that?
0
8411
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8832
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8617
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7449
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6240
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4230
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2821
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
2
1821
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.