From pcguy11 at live.com Wed Nov 10 17:37:02 2010 From: pcguy11 at live.com (Greg White) Date: Wed, 10 Nov 2010 19:37:02 -0600 Subject: [splint-discuss] splint doesn't like unsigned long long? Message-ID: Hi, I ran splint on my program and received the following results: test.c:51:53: Duplicate long qualifier on non-int ? Duplicate type qualifiers not supported by ISO standard. (Use -duplicatequals ? to inhibit warning) test.c:51:29: Format argument 1 to printf (%llu) expects unsigned int gets ???????????????????? unsigned long long: my_thread.finalsize ? To ignore type qualifiers in type comparisons use +ignorequals. ?? test.c:51:18: Corresponding format code The line of code is: printf("%llu bytes\t",my_thread.finalsize); The variables are: struct child_thread_data{ unsigned long long finalsize; }; static struct child_thread_data my_thread; Did I do something wrong? Thanks, Greg From ok at cs.otago.ac.nz Wed Nov 10 18:30:47 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu, 11 Nov 2010 15:30:47 +1300 Subject: [splint-discuss] splint doesn't like unsigned long long? In-Reply-To: References: Message-ID: On 11/11/2010, at 2:37 PM, Greg White wrote: > I ran splint on my program and received the following results: ... > > Did I do something wrong? You used a C89 checker. %lld is not legal C89. From pcguy11 at live.com Sat Nov 13 06:31:05 2010 From: pcguy11 at live.com (Greg White) Date: Sat, 13 Nov 2010 08:31:05 -0600 Subject: [splint-discuss] splint doesn't like unsigned long long? In-Reply-To: References: , Message-ID: > On 11/11/2010, at 2:37 PM, Greg wrote: > > I ran splint on my program and received the following results: > ... > > > > Did I do something wrong? > > You used a C89 checker. %lld is not legal C89. What is the C89 equivalent? Unsigned long isn't large enough and I don't need any decimal places. Can float handle large numbers without decimal places? If there is no long long C89 equivalent then How do I test for C99 compliance? Thanks, -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20101113/b7ca2393/attachment.html From n3npq at mac.com Sat Nov 13 09:17:03 2010 From: n3npq at mac.com (Jeff Johnson) Date: Sat, 13 Nov 2010 12:17:03 -0500 Subject: [splint-discuss] splint doesn't like unsigned long long? In-Reply-To: References: Message-ID: <091881F0-A192-40A6-8A22-4F3FCF7C9858@mac.com> On Nov 13, 2010, at 9:31 AM, Greg White wrote: > > On 11/11/2010, at 2:37 PM, Greg wrote: > > > I ran splint on my program and received the following results: > > ... > > > > > > Did I do something wrong? > > > > You used a C89 checker. %lld is not legal C89. > > What is the C89 equivalent? Unsigned long isn't large enough and I don't need any decimal places. Can float handle large numbers without decimal places? If there is no long long C89 equivalent then How do I test for C99 compliance? > There is a simple and expedient hack that can be done too. Instead of using "%lld" one can use "%ld" and add a cast to the long long integer. That will remove the warning does get on to more interesting flaws that splint can find in all C code. Please note "expedient hack". 73 de Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20101113/4f898f3c/attachment.html From splint at sympatico.ca Sun Nov 14 14:02:46 2010 From: splint at sympatico.ca (Bill Pringlemeir) Date: Sun, 14 Nov 2010 17:02:46 -0500 Subject: [splint-discuss] splint doesn't like unsigned long long? In-Reply-To: (Greg White's message of "Wed, 10 Nov 2010 19:37:02 -0600") References: Message-ID: On 10 Nov 2010, pcguy11 at live.com wrote: > I ran splint on my program and received the following results: [snip] > The line of code is: > printf("%llu bytes\t",my_thread.finalsize); > > The variables are: > struct child_thread_data{ > unsigned long long finalsize; Can you re-run your code with the latest CVS version? This now passes, [./splint +nof test.c] #include static struct child_thread_data{ unsigned long long finalsize; } my_thread; int foo(void) { printf("%llu bytes\t",my_thread.finalsize); return 0; } Splint was handling 'long long', but not the unsigned variant. Thanks, Bill Pringlemeir. -- Married men live longer than single men, but married men are much more willing to die - Dilworth From splint at sympatico.ca Sun Nov 14 14:02:46 2010 From: splint at sympatico.ca (Bill Pringlemeir) Date: Sun, 14 Nov 2010 17:02:46 -0500 Subject: [splint-discuss] splint doesn't like unsigned long long? In-Reply-To: (Greg White's message of "Wed, 10 Nov 2010 19:37:02 -0600") References: Message-ID: On 10 Nov 2010, pcguy11 at live.com wrote: > I ran splint on my program and received the following results: [snip] > The line of code is: > printf("%llu bytes\t",my_thread.finalsize); > > The variables are: > struct child_thread_data{ > unsigned long long finalsize; Can you re-run your code with the latest CVS version? This now passes, [./splint +nof test.c] #include static struct child_thread_data{ unsigned long long finalsize; } my_thread; int foo(void) { printf("%llu bytes\t",my_thread.finalsize); return 0; } Splint was handling 'long long', but not the unsigned variant. Thanks, Bill Pringlemeir. -- Married men live longer than single men, but married men are much more willing to die - Dilworth From ok at cs.otago.ac.nz Sun Nov 14 17:17:54 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Mon, 15 Nov 2010 14:17:54 +1300 Subject: [splint-discuss] splint doesn't like unsigned long long? In-Reply-To: References: , Message-ID: <18693116-2157-49F8-84B0-ACCDA30CD7E1@cs.otago.ac.nz> On 14/11/2010, at 3:31 AM, Greg White wrote: > > What is the C89 equivalent? There is no C89 equivalent of %lld. There is no C89 way to get integers that are *guaranteed* to be 64 bits, although there is nothing in C89 that says longs can't be that size, and indeed in some compilation modules with some compilers they *will* be. Here is a transcript. m% cat foo.c #include int main(void) { printf("%d\n", (int)sizeof (long int)); return 0; } m% gcc -m64 foo.c m% a.out 8 Indeed, C89 orthodoxy was that this was the way that you *ought* to get at 64-bit integers, but they got overtaken by gcc practice, and decided to make the de facto standard the de jure one. > > Unsigned long isn't large enough and I don't need any decimal places. Can float handle large numbers without decimal places? IEEE 'double' arithmetic gives you *exact* integer addition, subtraction, comparison, and multiplication for numbers up to ?2^53 or thereabouts. Division and remainder are trickier, but you can program them using fmod(). > If there is no long long C89 equivalent then How do I test for C99 compliance? I wish I had the time to put some work into splint instead of just using it. gcc -ansi -pedantic -std=c99 isn't _perfect_, but it's a lot better than nothing. From nsriniva at gmail.com Mon Nov 15 05:21:41 2010 From: nsriniva at gmail.com (Naveen Srinivasan) Date: Mon, 15 Nov 2010 18:51:41 +0530 Subject: [splint-discuss] Parse error ... when processing a #define for a Pragma in gcc Message-ID: Hello All I am a newbie to Splint. I am having a problem in getting Splint to parse this code. The simplified version of the code is presented here. When I use the below command, * splint -DUSE_GCC=1 -I. testmain.c *I get the following error, * Splint 3.1.1 --- 19 Jul 2006 my_includes.h:3:21: Parse Error. (For help on parse errors, see splint -help parseerrors.) *** Cannot continue. *Could you guys tell me whats wrong and how I can fix this? The easiest fix would be to use the pragma's instead of the USE_ALIGN.. macros in my_includes.h file. But is there some other way to fix this error? Here are the contents of the source files. *testmain.c: * #include #include "my_includes.h" int main() { printf("Hello There!\n"); return 0; } *my_includes.h* #include "my_macros.h" USE_ALIGN_SAVE USE_ALIGN_NATURAL typedef struct { int a; int b; int c; char *d; char *e; char *f; }myprofile; USE_ALIGN_RESTORE *my_macros.h:* #if defined(USE_GCC) # define USE_ALIGN_NATURAL _Pragma("pack()") # define USE_ALIGN_SAVE _Pragma("pack(push)") # define USE_ALIGN_RESTORE _Pragma("pack(pop)") #endif Thanks Naveen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20101115/483c1ce7/attachment-0001.html From Wenzel at bbr-vt.de Mon Nov 15 05:48:33 2010 From: Wenzel at bbr-vt.de (Wenzel, Bodo) Date: Mon, 15 Nov 2010 14:48:33 +0100 Subject: [splint-discuss] Parse error ... when processing a #define for a Pragma in gcc In-Reply-To: References: Message-ID: <46B6459B655D7342AB97371E8B7CD8B80130066F@sv-exch.BBR.local> Just as a work-around, you might like to expand my_macros.h like this and to let USE_GCC undefined. #if defined(USE_GCC) # define USE_ALIGN_NATURAL _Pragma("pack()") # define USE_ALIGN_SAVE _Pragma("pack(push)") # define USE_ALIGN_RESTORE _Pragma("pack(pop)") #else # define USE_ALIGN_NATURAL # define USE_ALIGN_SAVE # define USE_ALIGN_RESTORE #endif By the way, when Splint parses a source, S_SPLINT_S is defined. HTH, Bodo Wenzel From Michael.Wojcik at microfocus.com Mon Nov 15 06:31:40 2010 From: Michael.Wojcik at microfocus.com (Michael Wojcik) Date: Mon, 15 Nov 2010 06:31:40 -0800 Subject: [splint-discuss] Parse error ... when processing a #define fora Pragma in gcc In-Reply-To: <46B6459B655D7342AB97371E8B7CD8B80130066F@sv-exch.BBR.local> References: <46B6459B655D7342AB97371E8B7CD8B80130066F@sv-exch.BBR.local> Message-ID: <81F42F63D5BB344ABF294F8E80990C7902782A30@MTV-EXCHANGE.microfocus.com> > From: splint-discuss-bounces at cs.virginia.edu [mailto:splint-discuss- > bounces at cs.virginia.edu] On Behalf Of Wenzel, Bodo > Sent: Monday, 15 November, 2010 08:49 > > Just as a work-around, you might like to expand my_macros.h like this > and to let USE_GCC undefined. > > #if defined(USE_GCC) > # define USE_ALIGN_NATURAL _Pragma("pack()") > # define USE_ALIGN_SAVE _Pragma("pack(push)") > # define USE_ALIGN_RESTORE _Pragma("pack(pop)") > #else > # define USE_ALIGN_NATURAL > # define USE_ALIGN_SAVE > # define USE_ALIGN_RESTORE > #endif > > By the way, when Splint parses a source, S_SPLINT_S is defined. So rather than changing whether USE_GCC is defined, depending on whether you're building or running splint, you could change the first line to: #if defined USE_GCC && !defined S_SPLINT_S (Note parentheses are not required around the operand to the "defined" operator. It's not a function.) Alternatively, you could add: #if defined S_SPLINT_S # define _Pragma(x) #endif at the top of the file. -- Michael Wojcik Principal Software Systems Developer, Micro Focus From ok at cs.otago.ac.nz Mon Nov 15 14:42:42 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue, 16 Nov 2010 11:42:42 +1300 Subject: [splint-discuss] Parse error ... when processing a #define for a Pragma in gcc In-Reply-To: References: Message-ID: On 16/11/2010, at 2:21 AM, Naveen Srinivasan wrote: [SPlint falls over when it processes a line USE_ALIGN_SAVE that expands to _Pragma("pack(push)") ] _Pragma was introduced in C99. SPlint is basically a C89 checker, although a fair bit has been done to update it. The simplest thing is to put #ifdef S_SPLINT_S #define _Pragma(x) #endif in one of your macro files. From ok at cs.otago.ac.nz Mon Nov 15 14:42:42 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue, 16 Nov 2010 11:42:42 +1300 Subject: [splint-discuss] Parse error ... when processing a #define for a Pragma in gcc In-Reply-To: References: Message-ID: On 16/11/2010, at 2:21 AM, Naveen Srinivasan wrote: [SPlint falls over when it processes a line USE_ALIGN_SAVE that expands to _Pragma("pack(push)") ] _Pragma was introduced in C99. SPlint is basically a C89 checker, although a fair bit has been done to update it. The simplest thing is to put #ifdef S_SPLINT_S #define _Pragma(x) #endif in one of your macro files. From nsriniva at gmail.com Mon Nov 15 23:43:22 2010 From: nsriniva at gmail.com (Naveen Srinivasan) Date: Tue, 16 Nov 2010 13:13:22 +0530 Subject: [splint-discuss] Parse error ... when processing a #define for a Pragma in gcc In-Reply-To: References: Message-ID: Hello All Thanks for your inputs. I made the declarations like below and it works fine now. #if defined(USE_GCC) #ifdef S_SPLINT_S # define USE_ALIGN_NATURAL # define USE_ALIGN_SAVE # define USE_ALIGN_RESTORE #else # define USE_ALIGN_NATURAL _Pragma("pack()") # define USE_ALIGN_SAVE _Pragma("pack(push)") # define USE_ALIGN_RESTORE _Pragma("pack(pop)") #endif Thanks Naveen On Tue, Nov 16, 2010 at 4:12 AM, Richard O'Keefe wrote: > > On 16/11/2010, at 2:21 AM, Naveen Srinivasan wrote: > [SPlint falls over when it processes a line > USE_ALIGN_SAVE > that expands to > _Pragma("pack(push)") > ] > > _Pragma was introduced in C99. SPlint is basically a C89 checker, > although a fair bit has been done to update it. The simplest thing > is to put > > #ifdef S_SPLINT_S > #define _Pragma(x) > #endif > > in one of your macro files. > > _______________________________________________ > splint-discuss mailing list > splint-discuss at mail.cs.virginia.edu > http://www.cs.virginia.edu/mailman/listinfo/splint-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20101116/6903817f/attachment.html From nsriniva at gmail.com Mon Nov 15 23:43:22 2010 From: nsriniva at gmail.com (Naveen Srinivasan) Date: Tue, 16 Nov 2010 13:13:22 +0530 Subject: [splint-discuss] Parse error ... when processing a #define for a Pragma in gcc In-Reply-To: References: Message-ID: Hello All Thanks for your inputs. I made the declarations like below and it works fine now. #if defined(USE_GCC) #ifdef S_SPLINT_S # define USE_ALIGN_NATURAL # define USE_ALIGN_SAVE # define USE_ALIGN_RESTORE #else # define USE_ALIGN_NATURAL _Pragma("pack()") # define USE_ALIGN_SAVE _Pragma("pack(push)") # define USE_ALIGN_RESTORE _Pragma("pack(pop)") #endif Thanks Naveen On Tue, Nov 16, 2010 at 4:12 AM, Richard O'Keefe wrote: > > On 16/11/2010, at 2:21 AM, Naveen Srinivasan wrote: > [SPlint falls over when it processes a line > USE_ALIGN_SAVE > that expands to > _Pragma("pack(push)") > ] > > _Pragma was introduced in C99. SPlint is basically a C89 checker, > although a fair bit has been done to update it. The simplest thing > is to put > > #ifdef S_SPLINT_S > #define _Pragma(x) > #endif > > in one of your macro files. > > _______________________________________________ > splint-discuss mailing list > splint-discuss at mail.cs.virginia.edu > http://www.cs.virginia.edu/mailman/listinfo/splint-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20101116/6903817f/attachment-0001.html From pcguy11 at live.com Sat Nov 20 12:12:05 2010 From: pcguy11 at live.com (Greg White) Date: Sat, 20 Nov 2010 14:12:05 -0600 Subject: [splint-discuss] splint doesn't like unsigned long long? In-Reply-To: References: , Message-ID: ---------------------------------------- > From: splint at sympatico.ca > To: splint-discuss at cs.virginia.edu > Date: Sun, 14 Nov 2010 17:02:46 -0500 > CC: splint-discuss at mail.cs.virginia.edu > Subject: Re: [splint-discuss] splint doesn't like unsigned long long? > > On 10 Nov 2010, pcguy11 at live.com wrote: > > > > I ran splint on my program and received the following results: > > [snip] > > > The line of code is: > > printf("%llu bytes\t",my_thread.finalsize); > > > > The variables are: > > struct child_thread_data{ > > unsigned long long finalsize; > > Can you re-run your code with the latest CVS version? This now passes, I downloaded the CVS version and the unsigned long long warnings went away. Thank you for the tip. From pcguy11 at live.com Sat Nov 20 12:12:05 2010 From: pcguy11 at live.com (Greg White) Date: Sat, 20 Nov 2010 14:12:05 -0600 Subject: [splint-discuss] splint doesn't like unsigned long long? In-Reply-To: References: , Message-ID: ---------------------------------------- > From: splint at sympatico.ca > To: splint-discuss at cs.virginia.edu > Date: Sun, 14 Nov 2010 17:02:46 -0500 > CC: splint-discuss at mail.cs.virginia.edu > Subject: Re: [splint-discuss] splint doesn't like unsigned long long? > > On 10 Nov 2010, pcguy11 at live.com wrote: > > > > I ran splint on my program and received the following results: > > [snip] > > > The line of code is: > > printf("%llu bytes\t",my_thread.finalsize); > > > > The variables are: > > struct child_thread_data{ > > unsigned long long finalsize; > > Can you re-run your code with the latest CVS version? This now passes, I downloaded the CVS version and the unsigned long long warnings went away. Thank you for the tip.