Issue or not?

2010-12-30
2013-05-28
  • Andrey Karpov

    Andrey Karpov - 2010-12-30

    I've tested the PVS-Studio 4.0 analyzer with some of the projects from sourceforge.net.

    I found a suspicious piece of code:

    BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)
    {
      ...
      case IDM_FILE_OPEN:
        // Refer to the tutorial for an example of OnFileOpen
        OnFileOpen();
        return TRUE;
      case IDM_FILE_SAVE:
        // Refer to the tutorial for an example of OnFileSave
        OnFileSave();
        return TRUE;
      case IDM_FILE_SAVEAS:
        // Refer to the tutorial for an example of OnFileSaveAs
        OnFileSave();
        return TRUE;
      ...
    }
    

    PVS-Studio:
    V525 The code containing the collection of similar blocks. Check items 'OnFileOpen', 'OnFileSave', 'OnFileSave', 'OnFilePrint' in lines 37, 41, 45, 48. Frame mainfrm.cpp 37

    Perhaps there should be written "case IDM_FILE_SAVEAS: OnFileSaveAs()"?

     
  • David

    David - 2010-12-31

    Actually I'm happy with the code the way it is.
    The comments included with the code should make it quite clear what is intended here.

     

Log in to post a comment.