From patchwork Wed Nov 18 10:47:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Hai X-Patchwork-Id: 11914759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA6C8C5519F for ; Wed, 18 Nov 2020 10:45:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58444223C7 for ; Wed, 18 Nov 2020 10:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbgKRKoz (ORCPT ); Wed, 18 Nov 2020 05:44:55 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:7698 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726141AbgKRKoz (ORCPT ); Wed, 18 Nov 2020 05:44:55 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CbfZV11f6zkZkx; Wed, 18 Nov 2020 18:44:34 +0800 (CST) Received: from huawei.com (10.175.113.133) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Wed, 18 Nov 2020 18:44:48 +0800 From: Wang Hai To: , CC: , Subject: [PATCH v2] android/ion: fix error return code in opensocket() Date: Wed, 18 Nov 2020 18:47:42 +0800 Message-ID: <20201118104742.62817-1-wanghai38@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.133] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Fixes: 47a18c42d992 ("android/ion: userspace test utility for ion buffer sharing") Reported-by: Hulk Robot Signed-off-by: Wang Hai --- v1->v2: add missing ";" tools/testing/selftests/android/ion/ipcsocket.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/android/ion/ipcsocket.c b/tools/testing/selftests/android/ion/ipcsocket.c index 7dc521002095..13b3455ba39c 100644 --- a/tools/testing/selftests/android/ion/ipcsocket.c +++ b/tools/testing/selftests/android/ion/ipcsocket.c @@ -28,8 +28,9 @@ int opensocket(int *sockfd, const char *name, int connecttype) } *sockfd = ret; - if (setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, - (char *)&temp, sizeof(int)) < 0) { + ret = setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&temp, + sizeof(int)); + if (ret < 0) { fprintf(stderr, "<%s>: Failed setsockopt: <%s>\n", __func__, strerror(errno)); goto err;