From 2ee1a06f24895ea9067d9b026057581ff715aec8 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Sat, 12 Jun 2021 19:41:16 +0000 Subject: lpass: delete side effect --- src/lpass.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lpass.c b/src/lpass.c index 22e9eb8..d1ee817 100644 --- a/src/lpass.c +++ b/src/lpass.c @@ -46,6 +46,9 @@ static struct cmd_struct commands[] = { static struct cmd_struct *get_cmd(const char *name) { + if(!name) + return NULL; + struct cmd_struct *ptr; for(ptr = commands; ptr->cmd; ptr++) { if(strcmp(name, ptr->cmd) == 0) @@ -82,9 +85,8 @@ int main(int argc, char *argv[]) if(goto_maindir()) errprint_r(1, "%s", strerror(errno)); - char *cmd = (argv[1] != NULL) ? argv[1] : ""; - struct cmd_struct *ptr; - if((ptr = get_cmd(cmd))) + struct cmd_struct *ptr = get_cmd(argv[1]); + if(ptr) return ptr->func(argc, argv); return cmd_showtree(argc, argv); -- cgit v1.2.3-18-g5258