iron261 / openjpeg

Automatically exported from code.google.com/p/openjpeg
Other
0 stars 0 forks source link

bad use of case statement #381

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
see http://www.viva64.com/en/b/0271/#ID0EWAAG

typedef enum PROG_ORDER {
  PROG_UNKNOWN = -1,
  LRCP = 0,
  RLCP = 1,
  RPCL = 2,
  PCRL = 3,
  CPRL = 4
} OPJ_PROG_ORDER;

OPJ_INT32 pi_check_next_level(....)
{
  ....
  case 'P':
    switch(tcp->prg)
    {
      case LRCP||RLCP:
        if(tcp->prc_t == tcp->prcE){
          l=pi_check_next_level(i-1,cp,tileno,pino,prog);
  ....
}
PVS-Studio's diagnostic message: V560 A part of conditional expression is 
always true: RLCP. pi.c 1708

The programmer forgot how to use the 'case' operator properly. The statement 
"case LRCP||RLCP:" is equivalent to "case 1:". And this is obviously not what 
the programmer intended.

The correct code should look as follows:

case LRCP:
case RLCP:
And that's exactly what is written in other places of the program. Well, I 
would also add a comment – something like this:

case LRCP: // fall through
case RLCP:

Original issue reported on code.google.com by antonin on 24 Aug 2014 at 8:59

GoogleCodeExporter commented 9 years ago
still in  line 1111 of

 openjpeg-2.x-trunk-r2875/src/lib/openjp2/pi.c

winfried

Original comment by szukw...@arcor.de on 30 Aug 2014 at 12:47

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r2891.

Original comment by antonin on 30 Sep 2014 at 12:19