shared/shell: Fix compilation error
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 9 Jan 2019 15:42:47 +0000 (12:42 -0300)
committerhimanshu <h.himanshu@samsung.com>
Wed, 22 Jan 2020 08:53:01 +0000 (14:23 +0530)
asprintf return is not check which is catch by -Werror=unused-result
so in case asprintf fails don't set any prompt.

Change-Id: I8c0e3ea9151f8fb115246bde62a1850b43e7fecf
Signed-off-by: himanshu <h.himanshu@samsung.com>
src/shared/shell.c

index df366de..13912ac 100644 (file)
@@ -573,15 +573,12 @@ void bt_shell_prompt_input(const char *label, const char *msg,
        if (data.saved_prompt)
                return;
 
+       if (asprintf(&str, "[%s] %s ", label, msg) < 0)
+               return;
+
        data.saved_prompt = true;
        data.saved_func = func;
        data.saved_user_data = user_data;
-       err = asprintf(&str, "[%s] %s ", label, msg);
-
-       if (err < 0) {
-               free(str);
-               return;
-       }
 
        rl_save_prompt();
        bt_shell_set_prompt(str);