From: Peter Oskolkov Subject: [PATCH net-next v3] selftests: net: reuseport_addr_any: silence clang warning Date: Thu, 20 Dec 2018 16:41:52 -0800 Message-ID: <20181221004152.74421-1-posk@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: Peter Oskolkov , Peter Oskolkov To: David Miller , netdev@vger.kernel.org Return-path: Received: from mail-io1-f73.google.com ([209.85.166.73]:53120 "EHLO mail-io1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727993AbeLUAl6 (ORCPT ); Thu, 20 Dec 2018 19:41:58 -0500 Received: by mail-io1-f73.google.com with SMTP id h7so2847883iof.19 for ; Thu, 20 Dec 2018 16:41:57 -0800 (PST) Sender: netdev-owner@vger.kernel.org List-ID: Clang does not recognize that calls to error() terminate execution and complains about uninitialized variable use that happens after calls to error(). This noop patchset fixes this. Signed-off-by: Peter Oskolkov --- tools/testing/selftests/net/reuseport_addr_any.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/net/reuseport_addr_any.c b/tools/testing/selftests/net/reuseport_addr_any.c index 6f54d425dba9..c6233935fed1 100644 --- a/tools/testing/selftests/net/reuseport_addr_any.c +++ b/tools/testing/selftests/net/reuseport_addr_any.c @@ -60,6 +60,11 @@ static void build_rcv_fd(int family, int proto, int *rcv_fds, int count, break; default: error(1, 0, "Unsupported family %d", family); + /* clang does not recognize error() above as terminating + * the program, so it complains that saddr, sz are + * not initialized when this code path is taken. Silence it. + */ + return; } for (i = 0; i < count; ++i) { @@ -128,6 +133,11 @@ static int connect_and_send(int family, int proto) break; default: error(1, 0, "Unsupported family %d", family); + /* clang does not recognize error() above as terminating + * the program, so it complains that saddr, daddr, sz are + * not initialized when this code path is taken. Silence it. + */ + return -1; } fd = socket(family, proto, 0); -- 2.20.1.415.g653613c723-goog