client/advertising: Fixes errors found by scan-build
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 22 Jun 2022 18:16:18 +0000 (11:16 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
This fixes the following errors:

client/advertising.c:129:4: warning: Value stored to 'n' is never read
[deadcode.DeadStores]
                        n = sizeof(str) - 1;
                        ^   ~~~~~~~~~~~~~~~
client/advertising.c:1012:25: warning: Dereference of null pointer
(loaded from variable 'min') [core.NullDereference]
        if (ad.min_interval != *min) {
                               ^~~~

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
client/advertising.c

index ef7aa2e..f637604 100644 (file)
@@ -124,8 +124,6 @@ static void print_uuid(const char *uuid)
                        str[sizeof(str) - 3] = '.';
                        if (str[sizeof(str) - 4] == ' ')
                                str[sizeof(str) - 4] = '.';
-
-                       n = sizeof(str) - 1;
                }
 
                bt_shell_printf("UUID: %s(%s)\n", str, uuid);
@@ -1008,13 +1006,13 @@ void ad_advertise_interval(DBusConnection *conn, uint32_t *min, uint32_t *max)
                return bt_shell_noninteractive_quit(EXIT_SUCCESS);
        }
 
-       if (ad.min_interval != *min) {
+       if (min && ad.min_interval != *min) {
                ad.min_interval = *min;
                g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE,
                                                        "MinInterval");
        }
 
-       if (ad.max_interval != *max) {
+       if (max && ad.max_interval != *max) {
                ad.max_interval = *max;
                g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE,
                                                        "MaxInterval");