Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bad use of case statement #381

Closed
gcode-importer opened this issue Aug 24, 2014 · 2 comments
Closed

bad use of case statement #381

gcode-importer opened this issue Aug 24, 2014 · 2 comments

Comments

@gcode-importer
Copy link

Originally reported on Google Code with ID 381

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:

Reported by detonin on 2014-08-24 20:59:20

@gcode-importer
Copy link
Author

still in  line 1111 of

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

winfried

Reported by szukw000 on 2014-08-30 00:47:38

@gcode-importer
Copy link
Author

This issue was closed by revision r2891.

Reported by detonin on 2014-09-30 12:19:18

  • Status changed: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants