Skip to contentSkip to conversation

locking/ww_mutex: set ret variable on failure

PATCH In review [email protected] 2 participants 2 messages Sep 27, 2021 – Oct 11, 2021 Locking primitives

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 locking/ww_mutex: set ret variable on failure

From: Tom Rix <[email protected]>

Building with clang 13 produces this error test-ww_mutex.c:138:7: error: variable 'ret' is used
uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

                if (!ww_mutex_trylock(&mutex, &ctx)) {
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

On this failure set ret to -EINVAL as is similarly done in the function.

---
 kernel/locking/test-ww_mutex.c | 1 +
 1 file changed, 1 insertion(+)
kernel/locking/test-ww_mutex.c +1 -0
index d63ac411f36722..7dbac5dc02efb7 100644
@@ -137,6 +137,7 @@ static int test_aa(bool trylock)
 	} else {
 		if (!ww_mutex_trylock(&mutex, &ctx)) {
 			pr_err("%s: initial trylock failed!\n", __func__);
+			ret = -EINVAL;
 			goto out;
 		}
 	}
Signature · 1 line
2.26.3
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Mon, Sep 27, 2021 at 07:57:56AM -0700, [email protected] wrote:

From: Tom Rix <[email protected]>

Building with clang 13 produces this error test-ww_mutex.c:138:7: error: variable 'ret' is used
uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

                if (!ww_mutex_trylock(&mutex, &ctx)) {
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 7 lines

On this failure set ret to -EINVAL as is similarly done in the function.

---
 kernel/locking/test-ww_mutex.c | 1 +
 1 file changed, 1 insertion(+)

Will