Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WhiteSpaces in .splintrc preprocessor directive -D

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?

like image 857
Bastian Ebeling Avatar asked Mar 05 '13 09:03

Bastian Ebeling


1 Answers

--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.

like image 156
Ortomala Lokni Avatar answered Dec 25 '22 12:12

Ortomala Lokni