Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5402006rwb; Wed, 9 Aug 2023 03:46:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaYSZd2sqb3bStIndXp6Vm4g2N51VriaSgN2czJ77jbN9BKDyOBoFGsvHuqLyKhYg4tv6C X-Received: by 2002:a17:902:d4cb:b0:1b7:e646:4cc4 with SMTP id o11-20020a170902d4cb00b001b7e6464cc4mr2440385plg.28.1691578004031; Wed, 09 Aug 2023 03:46:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691578004; cv=none; d=google.com; s=arc-20160816; b=Lq8AgCVkNFOpyYamsgssFKV1mYNgqlM4WV27GD7tMFp3EFq0ODadIqN/M1+24tcApX Z++C2t92Bgm3NOOaO3Ii9k+a8JoaN3euSlLUG7ytu1dRFETADXLOprXJcBfnjaYmcnuP YB24V2vPe/ce4CLo4IuQhf2C5Q3z3DhJRMEkoIPAuiAXuQyy8X7wrg4MKlvhLVmKAYyE AnCuylBhPs+i1lxG65skXhrBJ4rqWkpZDUwQvA+0pWrrt/cbP5dSncYH6r0poOb1zM6w bPFGyvkT2E2Fph712RBf8lJEmmi8j3EJtLqMsxnHndPaG5dDTqasOQ2kdS7t3FD+PAtO SdwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:to:content-language:user-agent:mime-version:date :message-id; bh=EvuJQXSSe40cX5NGFg9VHgGjEbwnqu6g+etQ9ZRA9zE=; fh=qkBUNQn6vHk5bOSGZHFwIDBmxZhX/vsCC6Te/67VLSM=; b=lkPJ8DPxumG8CpTsR2g3uQZuNDM+PIFPaITg9p9/aSwNopsA9CO7M51tnBViqoNLYA 5bWC81t2vY+RHKA6Jhnj1YjOCIAMEe16RjTMFYsc48f8unVUXK+7m/uOruoCLwo/IVq4 z9Sx10LO3GWThQVxqJ1IyysrgFKxpw9zD2YGOAElWGGpP7zd9AS6wPN1Dym0Q8Q/H0bh mEC9m3HUwlScAoS4ftw0Y78jU9iuoZDPDXzhWmcVcIpmUGnX+x5A8B14Uv6KearBmCgA ClFWKAo088oF+vUfsNLZ1XERptTrccS1cB331GPblkNL4iIkxG/28kBn+B43wVcI8oAj hWmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a170903120600b001b866e8af8dsi9293288plh.43.2023.08.09.03.46.33; Wed, 09 Aug 2023 03:46:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231171AbjHIKku (ORCPT + 56 others); Wed, 9 Aug 2023 06:40:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjHIKkt (ORCPT ); Wed, 9 Aug 2023 06:40:49 -0400 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAD7010F3; Wed, 9 Aug 2023 03:40:48 -0700 (PDT) Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5234f2c6c1dso1141296a12.1; Wed, 09 Aug 2023 03:40:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691577647; x=1692182447; h=content-transfer-encoding:in-reply-to:subject:from:references:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EvuJQXSSe40cX5NGFg9VHgGjEbwnqu6g+etQ9ZRA9zE=; b=HFiLVz/iAPrHEIm40lp1jz1+bWBSE6w3pT6iiH/C3Z7SuL2bYA0cGQVPNeY0ZJ/Z6W LawW1ox7MK1bwF9a3BKJOIBbCQJPtd3YS+/kLEhh8lyuioIhsd5rfKryda0kf8XxA0ib 0zlnnl+GKiBtvTFdx1eXEknnp7R9GwdDEDvv58PwB20vlt7jXIoXwzck2p+Y5wDZXYbu 3gnZ+hN+zkk4UHBz2FAFF+V0/ghN7NUoyPioJTfLAMw7ALk0szotupdFrgBw0AFK+i0w m6FUedPL7rOPdb+g8CAtdNruRmDPBZbNhD9zHu4z8mnl43+cPJzDFGFqGbOkPoEzBgaf cyfw== X-Gm-Message-State: AOJu0Yz02eHor9G5qfhvT/LE5eJXl94psdHijJMIBbL0bblsoJotmfK1 zr8+GET/wC1sfhbJY1bRrUI= X-Received: by 2002:aa7:c0da:0:b0:522:2b24:cf6 with SMTP id j26-20020aa7c0da000000b005222b240cf6mr1437954edp.42.1691577646894; Wed, 09 Aug 2023 03:40:46 -0700 (PDT) Received: from [192.168.1.58] (185-219-167-24-static.vivo.cz. [185.219.167.24]) by smtp.gmail.com with ESMTPSA id y5-20020a056402134500b005233647bc4csm4580155edw.59.2023.08.09.03.40.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Aug 2023 03:40:46 -0700 (PDT) Message-ID: <83f73eda-829d-2657-9f10-8ccf78522e5a@kernel.org> Date: Wed, 9 Aug 2023 12:40:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.1 Content-Language: en-US To: mickflemm@gmail.com, mcgrof@kernel.org, kvalo@kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org References: <20230807201057.340371-1-mahmoudmatook.mm@gmail.com> <92a26f67-1b24-ea35-2f39-7c0b75027617@kernel.org> <20230808194258.ocxnmqwzqlr6jpe4@mmaatuq-HP-Laptop-15-dy2xxx> From: Jiri Slaby Subject: Re: [PATCH] ath5k: fix WARNING opportunity for swap. In-Reply-To: <20230808194258.ocxnmqwzqlr6jpe4@mmaatuq-HP-Laptop-15-dy2xxx> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS 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-wireless@vger.kernel.org On 08. 08. 23, 21:42, Mahmoud Matook wrote: > On 08/08, Jiri Slaby wrote: > >> On 07. 08. 23, 22:10, Mahmoud Maatuq wrote: >>> coccinielle reported the following: >>> ./drivers/net/wireless/ath/ath5k/phy.c:1573:25-26: WARNING opportunity for swap() >> >> >> OK, once again: >> https://lore.kernel.org/all/0c3acbd4-6ab2-5cc5-6293-54e30093cce2@kernel.org/ > > > I had a look at the commit history, to see why the original developer > didn't use sort() function, and name the array variable sort but found > nothing. > I have some doubts that he might did that intentionally, so not to call > sort() function for such small array It happens once in 10 s and in a work. No worries about that. > and avoid the cost of context switching. What context switching? >>> diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c >>> index 5797ef9c73d7..f87eb684f223 100644 >>> --- a/drivers/net/wireless/ath/ath5k/phy.c >>> +++ b/drivers/net/wireless/ath/ath5k/phy.c >>> @@ -1562,16 +1562,13 @@ static s16 >>> ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah) >>> { >>> s16 sort[ATH5K_NF_CAL_HIST_MAX]; >>> - s16 tmp; >>> int i, j; >>> memcpy(sort, ah->ah_nfcal_hist.nfval, sizeof(sort)); >>> for (i = 0; i < ATH5K_NF_CAL_HIST_MAX - 1; i++) { >>> for (j = 1; j < ATH5K_NF_CAL_HIST_MAX - i; j++) { >>> if (sort[j] > sort[j - 1]) { >>> - tmp = sort[j]; >>> - sort[j] = sort[j - 1]; >>> - sort[j - 1] = tmp; >>> + swap(sort[j], sort[j - 1]); >>> } >>> } >>> } >> >> -- >> js >> suse labs -- js suse labs