PVS-StudioWarnings

PVS-Studio warning V527 for Scilab

Nov 19th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. void GetenvB(char *name, char *env, int len)
  2. {
  3.   int ierr = 0, one = 1;
  4.   C2F(getenvc)(&ierr,name,env,&len,&one);
  5.   if (ierr == 0)
  6.   {
  7.     char *last = &env[len-1];
  8.     while ( *last == ' ' ) { last = '\0' ; }
  9.     last--;
  10.   }
  11.   ....
  12. }
  13.  
  14. Most likely this is what should be written here: while ( *last == ' ' ) { *last++ = '\0' ; }
  15.  
  16. This suspicious code was found in Scilab project by PVS-Studio static code analyzer.
  17. Warning message is:
  18. V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant: *last = '\0'. getenvb.c 24
  19.  
  20. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment