Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2462193iob; Fri, 6 May 2022 03:33:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjCPjZOFGZtuOv26qIHa2vZwfESuJG3Sq+xAbEGl6Uj619QeksXhk4umnfUWApi6HUq49h X-Received: by 2002:a05:6e02:1645:b0:2cf:1ee9:1934 with SMTP id v5-20020a056e02164500b002cf1ee91934mr1085686ilu.50.1651833190594; Fri, 06 May 2022 03:33:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651833190; cv=none; d=google.com; s=arc-20160816; b=UF3l+czvERv906IwXqcABMwvagN4ALQk2R2l1jQHR4R54F6AIbxfbvSmJRqU5PymPG BMnBlaGm3Dwbyjv6hN1bTa3ypssa8gDZN9nl4m0tog5y3cE7ZtIZUemo5LJggSBmkvrD Oef9FdwA+D5W9K+Ib5jTCu/TCDa5bzbxTRviCpX5zCyu9B44ekppx8fe0/y+7c5G4h/r l3zr08MtWDu1+WUHXVuwyVUlNKJppu6eYrd3FS7DnDQbQSDsxvVft3wjdpQo/kN1cMhk pvRtbmILEE0mTH9FdnYcN5rkWQJY/Fc64EkRXYUJ6c7ITqIA8tXT5BetypbEq9i0GSW9 Z/tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=qkm99XlV95oopP5qgX2XL7m4YnEu2XjLBkDpAf+j9gE=; b=02MgzvqZ6+IjVlqL87UBh/y2d+uwPKQ+5bRSa0Sw7zJVxZ85mLBNqlWAyBA65K0qlB BjBEEj83dP6xbZIkHFv+oiOv56AYU04qbPnr4bIrMhej0efftsjf2KWn7lRUwOIq2ANk 37RrGhfC2/Y1uqcNtFhVMARe9BmjWdk2hqbXMgWXPp346x8//6ZZlEM/lAS4WGAgWJBA BuoEJyugaSUKleDxmn45XemCvHYRHa3Y6tysj8uo3JsFtnoyVB/aLVM9esQfkBburZRV D2g8nchWSAWhCLbMJUffzmE9IfZ+YAHzFovHHguA0heLFzBQTGg6kJLPSJ73anEV0nmD dGCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a056602010b00b00657bacb5455si2051810iot.83.2022.05.06.03.32.57; Fri, 06 May 2022 03:33:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346607AbiEEITm (ORCPT + 99 others); Thu, 5 May 2022 04:19:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238526AbiEEITg (ORCPT ); Thu, 5 May 2022 04:19:36 -0400 Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D553529CB8 for ; Thu, 5 May 2022 01:15:54 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R481e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VCIxWfR_1651738540; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0VCIxWfR_1651738540) by smtp.aliyun-inc.com(127.0.0.1); Thu, 05 May 2022 16:15:46 +0800 From: Jiapeng Chong To: arnd@arndb.de Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, Jiapeng Chong , Abaci Robot Subject: [PATCH] altera-stapl: Use swap() instead of open coding it Date: Thu, 5 May 2022 16:15:39 +0800 Message-Id: <20220505081539.91575-1-jiapeng.chong@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.7.g153144c MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clean the following coccicheck warning: ./drivers/misc/altera-stapl/altera.c:955:51-52: WARNING opportunity for swap(). Reported-by: Abaci Robot Signed-off-by: Jiapeng Chong --- drivers/misc/altera-stapl/altera.c | 56 +++++++++--------------------- 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/drivers/misc/altera-stapl/altera.c b/drivers/misc/altera-stapl/altera.c index 92c0611034b0..075f3a36d512 100644 --- a/drivers/misc/altera-stapl/altera.c +++ b/drivers/misc/altera-stapl/altera.c @@ -530,11 +530,8 @@ static int altera_execute(struct altera_state *astate, } break; case OP_SWP: - if (altera_check_stack(stack_ptr, 2, &status)) { - long_tmp = stack[stack_ptr - 2]; - stack[stack_ptr - 2] = stack[stack_ptr - 1]; - stack[stack_ptr - 1] = long_tmp; - } + if (altera_check_stack(stack_ptr, 2, &status)) + swap(stack[stack_ptr - 2], stack[stack_ptr - 1]); break; case OP_ADD: if (altera_check_stack(stack_ptr, 2, &status)) { @@ -912,34 +909,22 @@ static int altera_execute(struct altera_state *astate, */ /* SWP */ - if (altera_check_stack(stack_ptr, 2, &status)) { - long_tmp = stack[stack_ptr - 2]; - stack[stack_ptr - 2] = stack[stack_ptr - 1]; - stack[stack_ptr - 1] = long_tmp; - } + if (altera_check_stack(stack_ptr, 2, &status)) + swap(stack[stack_ptr - 2], stack[stack_ptr - 1]); /* SWPN 7 */ index = 7 + 1; - if (altera_check_stack(stack_ptr, index, &status)) { - long_tmp = stack[stack_ptr - index]; - stack[stack_ptr - index] = stack[stack_ptr - 1]; - stack[stack_ptr - 1] = long_tmp; - } + if (altera_check_stack(stack_ptr, index, &status)) + swap(stack[stack_ptr - index], stack[stack_ptr - 1]); /* SWP */ - if (altera_check_stack(stack_ptr, 2, &status)) { - long_tmp = stack[stack_ptr - 2]; - stack[stack_ptr - 2] = stack[stack_ptr - 1]; - stack[stack_ptr - 1] = long_tmp; - } + if (altera_check_stack(stack_ptr, 2, &status)) + swap(stack[stack_ptr - 2], stack[stack_ptr - 1]); /* SWPN 6 */ index = 6 + 1; - if (altera_check_stack(stack_ptr, index, &status)) { - long_tmp = stack[stack_ptr - index]; - stack[stack_ptr - index] = stack[stack_ptr - 1]; - stack[stack_ptr - 1] = long_tmp; - } + if (altera_check_stack(stack_ptr, index, &status)) + swap(stack[stack_ptr - index], stack[stack_ptr - 1]); /* DUPN 8 */ index = 8 + 1; @@ -950,18 +935,12 @@ static int altera_execute(struct altera_state *astate, /* SWPN 2 */ index = 2 + 1; - if (altera_check_stack(stack_ptr, index, &status)) { - long_tmp = stack[stack_ptr - index]; - stack[stack_ptr - index] = stack[stack_ptr - 1]; - stack[stack_ptr - 1] = long_tmp; - } + if (altera_check_stack(stack_ptr, index, &status)) + swap(stack[stack_ptr - index], stack[stack_ptr - 1]); /* SWP */ - if (altera_check_stack(stack_ptr, 2, &status)) { - long_tmp = stack[stack_ptr - 2]; - stack[stack_ptr - 2] = stack[stack_ptr - 1]; - stack[stack_ptr - 1] = long_tmp; - } + if (altera_check_stack(stack_ptr, 2, &status)) + swap(stack[stack_ptr - 2], stack[stack_ptr - 1]); /* DUPN 6 */ index = 6 + 1; @@ -1075,11 +1054,8 @@ static int altera_execute(struct altera_state *astate, * to swap with top element */ index = (args[0]) + 1; - if (altera_check_stack(stack_ptr, index, &status)) { - long_tmp = stack[stack_ptr - index]; - stack[stack_ptr - index] = stack[stack_ptr - 1]; - stack[stack_ptr - 1] = long_tmp; - } + if (altera_check_stack(stack_ptr, index, &status)) + swap(stack[stack_ptr - index], stack[stack_ptr - 1]); break; case OP_DUPN: /* -- 2.20.1.7.g153144c