From patchwork Wed Nov 2 22:36:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 14514 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp187298wru; Wed, 2 Nov 2022 15:52:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76lbe1D2lfbFXzHMieNFKhCxg8dVzfPjri02Y1NVUpqkja7twxbEnh/XRKj+OQbumXZ/P6 X-Received: by 2002:a17:90a:7301:b0:213:8a08:2f18 with SMTP id m1-20020a17090a730100b002138a082f18mr28661477pjk.50.1667429552425; Wed, 02 Nov 2022 15:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667429552; cv=none; d=google.com; s=arc-20160816; b=NMLYxD9YK95+pBbs2ha40Ef6v5iCUvBtoS9xXniGsoRbSjuQddJETFJ+Oi7CthxDhY VRGAk7m63glymuxj/KRScbnX/NBkvBJCqQL57qH3bEuPUaso1Ri4Tg6KgTUHj6adMjBF qHqbR/cjUCidPIaJRDwp9/N6LwDJ9tiswo0AKMlIWnc92EChBdiliJY2EXDyc0iWPYUC CjatOua5MUHfNyc0R+0UZASzR4VsZQPt6shsvFfaKIivGk3t7kW3CpVde+J9P1/WOkix saLgu/jaH2rZLAvxuhM85skhqkCTKcbyNsCiCbGMFdg+jhmZYJxvHTkfxGNYConrSlvh aGlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date:dkim-signature; bh=MwtcWZZ1t1lBXc7++k9TiSX211tpec0jJT1qpwrzh+M=; b=AzOPHOMwSihX/eafgQxpw+emh4eG7EPtQBIeGRTl34EM/z0U1vz2s3auOqFC+nBHSn 5eI47acyGj43lCgnKo9QOxsSUmfEp3K+v9S38CMxw9RniLMVgfFnRnL5A7CpqX0Is65c w4vdT/hmCcj9V6kuruUZqOfs1FudF9eBy1OQRm3R8hcA98K0tbyBZDaDO59yiVU8vDSA jCT4aZnfJcJylbG2T0uANXCXpp3P0rV35P5UKz75/KokoNBDhcgj8wWhzwUsju7aX+Hh JcFhmwtHStQJdiocRhkQlCTEIlvo+1FX8aXJUlP1eSbY9Do9Cqpm2Cjr8xrx6+kDz1zn yQdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=eLa3HMC9; 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=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cv21-20020a17090afd1500b001fe1c9436b1si3257704pjb.86.2022.11.02.15.52.19; Wed, 02 Nov 2022 15:52:32 -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; dkim=fail header.i=@mailo.com header.s=mailo header.b=eLa3HMC9; 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=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231526AbiKBWhP (ORCPT + 99 others); Wed, 2 Nov 2022 18:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbiKBWhO (ORCPT ); Wed, 2 Nov 2022 18:37:14 -0400 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9506BE25 for ; Wed, 2 Nov 2022 15:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1667428623; bh=Jh9hVKlG9E8M6+Hg4/uFDmdMr+5rCinh9+KF12rxCMs=; h=X-EA-Auth:Date:From:To:Subject:Message-ID:MIME-Version: Content-Type; b=eLa3HMC9o56WEYZq2SgqNyfJWWMf14vSK+J+8Kjo/Wz4Z9/jOClxEgzxzq4VSyik9 yQAZGFrNuIQTvtblfxcgbc1kj8dt97CffGv8a3yBmVKLuT0w7bkCxxwzmmq8g5oatW xhEm4Xgo1HYeDvNL3ZxA2G1vE2+ROoZueYOczGe0= Received: by b-5.in.mailobj.net [192.168.90.15] with ESMTP via [213.182.55.206] Wed, 2 Nov 2022 23:37:03 +0100 (CET) X-EA-Auth: w+3zi4nkHeGs1aO9AAZFE88t8u3GtxhuNPQ5I+2Kebsq2h73girS4qV9PZWmt8dwhm8SNoKbKQoIgCfn4kr4gD0xympHdQW7 Date: Thu, 3 Nov 2022 04:06:59 +0530 From: Deepak R Varma To: outreachy@lists.linux.dev, Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] staging: rtl8192e: Use min_t/max_t macros for variable comparison Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748426610355967795?= X-GMAIL-MSGID: =?utf-8?q?1748426610355967795?= Simplify code by using min_t and max_t helper macros in place of lengthy if/else block oriented logical evaluation and value assignment. This issue is identified by coccicheck using the minmax.cocci file. Use the *_t variants of min/max macros to avoid compiler warnings about data typecast. Also, use u32 as type for min_t macro to avoid any truncation of data associated with enum constant HT_AGG_SIZE_32K. Signed-off-by: Deepak R Varma Tested-by: Philipp Hortmann --- drivers/staging/rtl8192e/rtl819x_HTProc.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) -- 2.34.1 diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 62aa8e893c34..ccb86660ab48 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -587,17 +587,12 @@ void HTOnAssocRsp(struct rtllib_device *ieee) else pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; } else { - if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) - pHTInfo->CurrentAMPDUFactor = - pPeerHTCap->MaxRxAMPDUFactor; - else - pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; + pHTInfo->CurrentAMPDUFactor = min_t(u32, pPeerHTCap->MaxRxAMPDUFactor, + HT_AGG_SIZE_32K); } } - if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) - pHTInfo->current_mpdu_density = pHTInfo->MPDU_Density; - else - pHTInfo->current_mpdu_density = pPeerHTCap->MPDUDensity; + pHTInfo->current_mpdu_density = max_t(u8, pHTInfo->MPDU_Density, + pPeerHTCap->MPDUDensity); if (pHTInfo->iot_action & HT_IOT_ACT_TX_USE_AMSDU_8K) { pHTInfo->bCurrentAMPDUEnable = false; pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE;