public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [bug report] scsi: elx: efct: Driver initialization routines
@ 2021-06-18  9:16 Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2021-06-18  9:16 UTC (permalink / raw)
  To: jsmart2021; +Cc: linux-scsi

Hello James Smart,

The patch 4df84e846624: "scsi: elx: efct: Driver initialization
routines" from Jun 1, 2021, leads to the following static checker
warning:

	drivers/scsi/elx/efct/efct_hw.c:348 efct_hw_iotype_is_originator()
	warn: signedness bug returning '(-5)'

drivers/scsi/elx/efct/efct_hw.c
   341  static u8 efct_hw_iotype_is_originator(u16 io_type)
               ^^

   342  {
   343          switch (io_type) {
   344          case EFCT_HW_FC_CT:
   345          case EFCT_HW_ELS_REQ:
   346                  return 0;
   347          default:
   348                  return -EIO;
                        ^^^^^^^^^^^^
   349          }
   350  }

Looking at the comments at the call site and the name of this function,
I wonder if it's supposed to be a boolean function which returns true
if it's the originator.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [bug report] scsi: elx: efct: Driver initialization routines
@ 2021-06-18 13:36 Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2021-06-18 13:36 UTC (permalink / raw)
  To: jsmart2021; +Cc: linux-scsi

Hello James Smart,

The patch 4df84e846624: "scsi: elx: efct: Driver initialization
routines" from Jun 1, 2021, leads to the following static checker
warning:

	drivers/scsi/elx/efct/efct_xport.c:46 efct_xport_init_debugfs()
	warn: 'efct_debugfs_root' is an error pointer or valid

drivers/scsi/elx/efct/efct_xport.c
    39  static int
    40  efct_xport_init_debugfs(struct efct *efct)
    41  {
    42          /* Setup efct debugfs root directory */
    43          if (!efct_debugfs_root) {
    44                  efct_debugfs_root = debugfs_create_dir("efct", NULL);
    45                  atomic_set(&efct_debugfs_count, 0);
    46                  if (!efct_debugfs_root) {
    47                          efc_log_err(efct, "failed to create debugfs entry\n");
    48                          goto debugfs_fail;
    49                  }

This test can just be deleted.  We don't need to check for IS_ERR()
because it's okay if it fails.  Normally, drivers are not supposed to
check the return from debugfs_create_dir().

    50          }
    51  
    52          /* Create a directory for sessions in root */
    53          if (!efct->sess_debugfs_dir) {
    54                  efct->sess_debugfs_dir = debugfs_create_dir("sessions", NULL);
                                                                                ^^^^
This should be "efct_debugfs_root"


    55                  if (!efct->sess_debugfs_dir) {

Here, we do care so it should be updated to if (IS_ERR(efct->sess_debugfs_dir)) {

    56                          efc_log_err(efct,
    57                                      "failed to create debugfs entry for sessions\n");
    58                          goto debugfs_fail;
    59                  }
    60                  atomic_inc(&efct_debugfs_count);
    61          }
    62  
    63          return 0;
    64  
    65  debugfs_fail:
    66          return -EIO;
    67  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-18 13:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-18  9:16 [bug report] scsi: elx: efct: Driver initialization routines Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2021-06-18 13:36 Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox