Skip to contentSkip to conversation

zfcp: drop old default switch case which might paper over missing case

PATCH Hannes Reinecke 1 participant 1 message Nov 16, 2018 1 message not in the archive s390

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 30 lines · Steffen Maier

This was introduced with v2.6.27 commit 287ac01acf22 ("[SCSI] zfcp: Cleanup code in zfcp_erp.c") but would now suppress helpful -Wswitch compiler warnings when building with W=1 such as the following forced example:

drivers/s390/scsi/zfcp_erp.c: In function 'zfcp_erp_setup_act':
drivers/s390/scsi/zfcp_erp.c:220:2: warning: enumeration value 'ZFCP_ERP_ACTION_REOPEN_PORT' not handled in switch [-Wswitch]

   switch (need) {
   ^~~~~~

But then again, only with W=1 we would notice unhandled enum cases. Without the default cases and a missed unhandled enum case, the code might perform unforeseen things we might not want...

As of today, we never run through the removed default case, so removing it is no functional change.
In the future, we never should run through a default case but introduce the necessary specific case(s) to handle new functionality.

---
  drivers/s390/scsi/zfcp_erp.c | 3 ---
  1 file changed, 3 deletions(-)
drivers/s390/scsi/zfcp_erp.c +0 -0
index 9345fed3bb37..744a64680d5b 100644

drivers/s390/scsi/zfcp_erp.c static struct zfcp_erp_action *zfcp_erp_setup_act(enum zfcp_erp_act_type need, · line 262

Quoted 9 lines
drivers/s390/scsi/zfcp_erp.c +0 -3
@@ -257,9 +257,6 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(enum zfcp_erp_act_type need,
  		      ZFCP_STATUS_COMMON_RUNNING))
  			act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY;
  		break;
-
-	default:
-		return NULL;
  	}
 
  	WARN_ON_ONCE(erp_action->adapter != adapter);

Same here.
If you don't expect the code to run into this case, please do add a WARN_ON() or something so that it can be tracked down.

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: F. Imend�rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG N�rnberg)