Skip to contentSkip to conversation

storage: remove unused variables

PATCH In review James Prestwood 2 participants 4 messages Jun 10, 2022

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/3 storage: remove unused variables

The auto macros apparently made it difficult for gcc to detect, but clang was able to find them.

---
 src/storage.c | 2 --
 1 file changed, 2 deletions(-)
src/storage.c +0 -2
index aa8066b1..2100d08d 100644
@@ -456,11 +456,9 @@ char *__storage_encrypt(const struct l_settings *settings, const char *name,
 int __storage_decrypt(struct l_settings *settings, const char *ssid,
 				bool *encrypt)
 {
-	_auto_(l_settings_free) struct l_settings *security = NULL;
 	_auto_(l_free) uint8_t *encrypted = NULL;
 	_auto_(l_free) uint8_t *decrypted = NULL;
 	_auto_(l_free) uint8_t *salt = NULL;
-	_auto_(l_strv_free) char **embedded = NULL;
 	_auto_(l_strv_free) char **groups = NULL;
 	char **i;
 	size_t elen, slen;
Signature · 1 line
2.34.1
#1 lore raw

Hi James,

Quoted 6 lines · James Prestwood

The auto macros apparently made it difficult for gcc to detect, but clang was able to find them.

---
  src/storage.c | 2 --
  1 file changed, 2 deletions(-)

Patches 1-2 applied, thanks.

Regards,
-Denis

author
#2 lore raw

PATCH 2/3 p2p: fix warning for uninitialized variable (clang)

In reply to James Prestwood

This is actually a false positive only because p2p_device_validate_conn_wfd bails out if the IE is NULL which avoids using wfd_data_length. But its subtle and without inspecting the code it does seem like the length could be used uninitialized.

src/p2p.c:940:7: error: variable 'wfd_data_len' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

                if (dev->conn_own_wfd)
                    ^~~~~~~~~~~~~~~~~
src/p2p.c:946:8: note: uninitialized use occurs here
                                                        wfd_data_len))
                                                        ^~~~~~~~~~~~
src/p2p.c:940:3: note: remove the 'if' if its condition is always true
                if (dev->conn_own_wfd)
                ^~~~~~~~~~~~~~~~~~~~~~
src/p2p.c:906:23: note: initialize the variable 'wfd_data_len' to silence this warning
                ssize_t wfd_data_len;
                                    ^
                                     = 0
---
 src/p2p.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/p2p.c +1 -1
index ebd0f62b..a7207c30 100644
@@ -903,7 +903,7 @@ static void p2p_group_event(enum ap_event_type type, const void *event_data,
 	{
 		const struct ap_event_station_added_data *data = event_data;
 		L_AUTO_FREE_VAR(uint8_t *, wfd_data) = NULL;
-		ssize_t wfd_data_len;
+		ssize_t wfd_data_len = 0;
 		struct p2p_association_req req_info;
 		int r;
 
Signature · 1 line
2.34.1
author
#3 lore raw

PATCH 3/3 build: ignore unknown warnings/pragmas for CC=clang

In reply to James Prestwood

IWD uses a few pragmas to ignore warnings which clang does not support. For -Werror builds these cause build failures but can be fixed by ignoring unknown warnings and pragmas.

---
 acinclude.m4 | 5 +++++
 1 file changed, 5 insertions(+)
acinclude.m4 +5 -0
index a66a3746..3fd96236 100644
@@ -64,4 +64,9 @@ AC_DEFUN([COMPILER_FLAGS], [
 			CFLAGS+=" -Wcast-align"
 		fi
 	fi
+
+	if (test "$CC" = "clang"); then
+		CFLAGS+=" -Wno-unknown-warning-option"
+		CFLAGS+=" -Wno-unknown-pragmas"
+	fi
 ])
Signature · 1 line
2.34.1