6

I want to run splint on some of my sources within a debian stable environment.
I need to give the preprocessor directive -DUINT16_T='unsigned short' and as I need that very often. I'd like to place it inside my .splintrc file.
When running from commandline like splint -DUINT16_T='unsigned short' mysource.c it is working well. If moving this line into my .splintrc file

-DUINT16_T='unsigned short'
-I/usr/local/include/

the splint call results in

Cannot list files in .splintrc files:
                                 short' (probable missing + or -)
  A flag is not recognized or used in an incorrect way (Use -badflag to inhibit
  warning)

Has anyone a solution? (No alias, please).

For furher discussion I'll offer a mnwe (minimal not working example) hello.c, which might help:

#include <stdio.h>

int main (void)
{
  UINT16_T returnvalue=0;
  printf ("Hello, world!\n");
  return returnvalue;
}

The command gcc -DUINT16_T='unsigned short' hello.c runs fine - and also does splint -DUINT16_T='unsigned short' hello.c which of course claims

Return value type unsigned short int does not match declared type
                 int: returnvalue

But again, how can I include this DEFINE into my .splintrc?

Bastian Ebeling
  • 1,138
  • 11
  • 38

2 Answers2

1

--New answer--

What you are asking is just not implemented in splint.

If you look at the splint 3.1.2 rcfiles_loadFile function in rcfiles.c line 124

124          while ((c = *s) != '\0')
125             { /* remember to handle spaces and quotes in -D and -U ... */
126               if (escaped)
127                 {
128                   escaped = FALSE;
129                 }
130               else if (quoted)
131                 {
132                   if (c == '\\')
133                     {
134                       escaped = TRUE;
135                     }
136                   else if (c == '\"')
137                     {
138                       quoted = FALSE;
139                     }
140                   else
141                     {
142                       ;
143                     }
144                 }
145               else if (c == '\"')
146                 {
147                   quoted = TRUE;
148                 }
149               else
150                 {
151                  if (c == ' ' || c == '\t' || c == '\n')
152                    {
153                      /*@innerbreak@*/ break;
154                    }
155                }
156 
157               s++;
158               incColumn ();
159             }

You see that the comment in line 125 is a TODO for what you are asking.

I changed the line 151 to

151                  if (c == '\t' || c == '\n')

Compile, run and then your minimal not working example (without quotes in .splintrc) is passing the test without a problem.

However this modification is a bit rough since some splint unit tests are then failing.

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
  • I tried - and your file runs fine - but try #include int main (void) { UINT16_T returnvalue=0; printf ("Hello, world!\n"); return returnvalue; } then you'll see in only runs because the define is not used. So sad. Furhter hints/ideas? – Bastian Ebeling Aug 06 '14 at 13:56
0

Use double quotes not single quotes.

-DUINT16_T="unsigned short"
LennyB
  • 359
  • 1
  • 5
  • 14
  • At the moment I can not try, but having a look at the comment http://stackoverflow.com/questions/15220228/whitespaces-in-splintrc-preprocessor-directive-d/29901100?iemail=1&noredirect=1#comment33322234_15220228 I think also double quotes won't work. – Bastian Ebeling Apr 29 '15 at 11:27
  • 1
    Quotes in that comment doesn't apply to `.splintrc`. As you can see from the source code string gets `quoted` with `'\"'` char. – LennyB Apr 30 '15 at 13:07