isdn/capi: don't return NULL from capi_cmd2str()
authorTilman Schmidt <tilman@imap.cc>
Sat, 11 Oct 2014 11:46:30 +0000 (13:46 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Oct 2014 19:05:35 +0000 (15:05 -0400)
capi_cmd2str() is used in many places to build log messages.
None of them is prepared to handle NULL as a result.
Change the function to return printable string "INVALID_COMMAND"
instead.

Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/isdn/capi/capiutil.c

index 36835ef3f340613df957ce98a26d5c16eabec20c..36c1b37cea0ac4ba7f4578ae9ae28454dcd75c2e 100644 (file)
@@ -489,12 +489,17 @@ static char *mnames[] =
  * @cmd:       command number
  * @subcmd:    subcommand number
  *
- * Return value: static string, NULL if command/subcommand unknown
+ * Return value: static string
  */
 
 char *capi_cmd2str(u8 cmd, u8 subcmd)
 {
-       return mnames[command_2_index(cmd, subcmd)];
+       char *result;
+
+       result = mnames[command_2_index(cmd, subcmd)];
+       if (result == NULL)
+               result = "INVALID_COMMAND";
+       return result;
 }