SockDiag - fix a deadcode warning
Assignments in if statements are ugly anyway...
Fixes:
system/netd/server/SockDiag.cpp:146:10: error: Although the value stored to 'ret' is used in the enclosing expression, the value is never actually read from 'ret' [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
if ((ret = getaddrinfo(addrstr, nullptr, &hints, &res)) != 0) {
^
Test: builds
Bug: 155351989
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia5ad0ef3176b90915cba6c8a1b8626ead53d67f6
Merged-In: Ia5ad0ef3176b90915cba6c8a1b8626ead53d67f6
diff --git a/server/SockDiag.cpp b/server/SockDiag.cpp
index 3e1f384..44bda3b 100644
--- a/server/SockDiag.cpp
+++ b/server/SockDiag.cpp
@@ -139,13 +139,11 @@
addrinfo hints = { .ai_flags = AI_NUMERICHOST };
addrinfo *res;
in6_addr mapped = { .s6_addr32 = { 0, 0, htonl(0xffff), 0 } };
- int ret;
// TODO: refactor the netlink parsing code out of system/core, bring it into netd, and stop
// doing string conversions when they're not necessary.
- if ((ret = getaddrinfo(addrstr, nullptr, &hints, &res)) != 0) {
- return -EINVAL;
- }
+ int ret = getaddrinfo(addrstr, nullptr, &hints, &res);
+ if (ret != 0) return -EINVAL;
// So we don't have to call freeaddrinfo on every failure path.
ScopedAddrinfo resP(res);