Skip to content

Commit

Permalink
isdn/capi: don't return NULL from capi_cmd2str()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tilman Schmidt authored and David S. Miller committed Oct 14, 2014
1 parent 2bf3a09 commit 340184b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/isdn/capi/capiutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down

0 comments on commit 340184b

Please sign in to comment.