Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp411207yba; Fri, 3 May 2019 04:20:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmCkY5YQ17lYGQ791vNGAt5jbXbV4uvqbzafHjzFY63R10qWaDdw1djPvcXvd6KV4T9E+I X-Received: by 2002:a63:f817:: with SMTP id n23mr9688454pgh.302.1556882418344; Fri, 03 May 2019 04:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556882418; cv=none; d=google.com; s=arc-20160816; b=QhMgCf9FnEvkA3epoD7r+vhOsfxAPn9ONjmSco//Ialdx/b0Na+K/D7IxjSdoVpRP/ GQWr63Hsa7bk1IbSYw20OndXxvN2dkukscmert39o/Ko7qAgeeF4N6R5QcAE4rb7ajv0 Ffic945WxXVi+icZfU9eDTvDc8TT5qf2MALBfxkQ8uyxTVuQ6HPuPYStZrspuXkvT0Ex +9LRGzPwzRYmHdkF1+5Eec4brWxtikHydli/8sm5zDMqACpmiVd0xgO6m4HsDE84EmTD Ma3ktBB0pkrqHAFwOLu9p8ymvhdTuqaP5vgKtWy5sGcKM6eyVtjdz3Rml7LWT3vTsQxP VfOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:dmarc-filter :dkim-signature:dkim-signature; bh=OkhlZu0tZi0kNjptoCi3Lc82zIb7LrKy287qr2BklCw=; b=BEok48dVddioiadrR9URNdN/A1O7hiVlcJMitAjBwvwH9IHG2XKOvgOySXSh+ve1wq no2nWWTfHowgP+XghY4Vaf5eTicfy32VfLU9RqFGC5K2le9BDCBjr4YSnuo2wyQeXuj6 uwK8hI/LvEReVMgTz05ZOCZk2KzIj59nSib/qFJxCb/tzbz9ezh3R1KKfO+HByh3+DJI 1oXARhj7sCu41GoOpgiyVBB6lRtSsTkxaZaStaovZJcwcx2d/10vcUBRrKENpwx9u6k2 1aSahVRCybzw5qSaOeQzR+siGftb0vsrMagapAmq/oIBex6N3T5UynYF+yqUPXwNXP3B LMFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b="BVjzbW0/"; dkim=pass header.i=@codeaurora.org header.s=default header.b="n/N0SB/5"; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a187si1830136pgc.385.2019.05.03.04.19.55; Fri, 03 May 2019 04:20:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b="BVjzbW0/"; dkim=pass header.i=@codeaurora.org header.s=default header.b="n/N0SB/5"; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727425AbfECLHJ (ORCPT + 99 others); Fri, 3 May 2019 07:07:09 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:51078 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbfECLHJ (ORCPT ); Fri, 3 May 2019 07:07:09 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D1D6F60E57; Fri, 3 May 2019 11:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1556881628; bh=yIKJRIZdelLZOg0RH08ruz2IDQDLuCeHtYEyJ1svdtQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=BVjzbW0/d0icck08gn/12Q3Uvu4DsSvfOwMHwYdMisjgdCKhbLmacagOSNgFHvd39 XErTYrikfaDobPgw2q3m9mOqWL91BY349gqotJZRbqFOCoAVWcnma3GaPJzhs9P+P6 1hevSfk6dXC4wJNQyYJJ0TlePyg9X1naFtKGj+2c= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from potku.adurom.net (88-114-240-156.elisa-laajakaista.fi [88.114.240.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kvalo@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id F1143608D4; Fri, 3 May 2019 11:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1556881626; bh=yIKJRIZdelLZOg0RH08ruz2IDQDLuCeHtYEyJ1svdtQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=n/N0SB/5jCbtFRSD310ocyilBW9Jkr9L4YtNTX8hh/az3+gE+zCEncrTWrmF5v4du /WXTNrENwSyzEFBdCox0vgcDgjg+Tc77LVYwGCMItCnJIuKrI8K+sAAzb2iKDh36HK Jufds865swFEo9ltwbRFx+anhpmxfPcxo87jzi3E= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org F1143608D4 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: Cc: Subject: Re: [PATCH 5/6] rtw88: mac: remove dangerous while (1) References: <1556879502-16211-1-git-send-email-yhchuang@realtek.com> <1556879502-16211-6-git-send-email-yhchuang@realtek.com> Date: Fri, 03 May 2019 14:07:03 +0300 In-Reply-To: <1556879502-16211-6-git-send-email-yhchuang@realtek.com> (yhchuang@realtek.com's message of "Fri, 3 May 2019 18:31:41 +0800") Message-ID: <87r29fkd9k.fsf@kamboji.qca.qualcomm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org writes: > From: Yan-Hsuan Chuang > > Not to use while (1) to parse power sequence commands in an array. > Put the statement (when cmd is not NULL) instead to make the loop stop > when the next fetched command is NULL. > > Signed-off-by: Yan-Hsuan Chuang > --- > drivers/net/wireless/realtek/rtw88/mac.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/wireless/realtek/rtw88/mac.c b/drivers/net/wireless/realtek/rtw88/mac.c > index 25a923b..7487b2e 100644 > --- a/drivers/net/wireless/realtek/rtw88/mac.c > +++ b/drivers/net/wireless/realtek/rtw88/mac.c > @@ -203,17 +203,14 @@ static int rtw_pwr_seq_parser(struct rtw_dev *rtwdev, > return -EINVAL; > } > > - do { > - cmd = cmd_seq[idx]; > - if (!cmd) > - break; > - > + while ((cmd = cmd_seq[idx])) { > ret = rtw_sub_pwr_seq_parser(rtwdev, intf_mask, cut_mask, cmd); > if (ret) > return -EBUSY; > > + /* fetch next command */ > idx++; > - } while (1); > + }; I dount see how this is any better, with a suitable bug you can still have a neverending loop, right? I was thinking more something like this: count = 100; do { .... } while (count--); That way the won't be more than 100 loops no matter how many bugs there are :) Of course I have no idea what would be a good value for count. -- Kalle Valo