From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9F1A1DD9AC for ; Sun, 1 Mar 2026 19:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772394207; cv=none; b=ZQ/mV+jVi9ZDYiPMrhipl6j51PUcXnfcdZKbDLoRbo0eMhBikidJuza48nWIRltAFTl6n7Guv3lrpcA4riGosmV9vJ3narT4FMNAUOM+JsIy9aF6ATfiPgMrhwswVpfQYZuF4iaT2h6UUduAQbSs/+KSJQ/JAqKW+Bh6aH1V0FA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772394207; c=relaxed/simple; bh=NcMzH6acSXeXcbxMU/AXq6MMaANM7cxRWLTPHNxtsIc=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=hupzm48ir0snhaWP25AdcS1DkUBZKFvMjkxOsyjC/I/TPPRHGPGsR/IhNb1xAEtJkl0vpFPBAXaS+uC4Zd7c9NJ1JnfCbLHr29OPefTlHbMfbHoWzCc9CNa5MmvGloTtkL328f2S7CHJx0CbbaTaC37TaJObwYu1d1Ax1WDNJI8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=kyUylH0z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="kyUylH0z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15CD8C116C6; Sun, 1 Mar 2026 19:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1772394207; bh=NcMzH6acSXeXcbxMU/AXq6MMaANM7cxRWLTPHNxtsIc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kyUylH0zgmEdChscvtaduHbpFp+bsNdOdB2fWcyLz1RTBbThIWhonL8ws2vrUg/R1 wc5CSbg2j4ef9z7Fx22mChSrilSTAT0+Wei71CBxGVSdtW9/ax/S6h67SBODilt+L4 RusQKWRkRGafpyxkU+HiA4eOHoB/XUCJsl0NSZ2Y= Date: Sun, 1 Mar 2026 11:43:26 -0800 From: Andrew Morton To: Josh Law Cc: linux-kernel@vger.kernel.org, Josh Law Subject: Re: [PATCH 2/2] lib: glob: replace bitwise OR with logical operation on boolean Message-Id: <20260301114326.90d0fb7385d87919c59e2541@linux-foundation.org> In-Reply-To: References: <20260301152143.2572137-1-objecting@objecting.org> <20260301152143.2572137-2-objecting@objecting.org> <20260301112542.0d915c2388febccf0294b880@linux-foundation.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Sun, 1 Mar 2026 19:40:16 +0000 Josh Law wrote: > 1 Mar 2026 19:25:44 Andrew Morton : >=20 > > On Sun,=A0 1 Mar 2026 15:21:42 +0000 Josh Law w= rote: > >=20 > >> Using bitwise OR (|=3D) on a boolean variable is valid C, but replacin= g it with a direct logical assignment makes the intent clearer and appeases= strict static analysis tools. > >>=20 > >=20 > > Fair enough. > >=20 > >> --- a/lib/glob.c > >> +++ b/lib/glob.c > >> @@ -96,7 +96,8 @@ bool __pure glob_match(char const *pat, char const *= str) > >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 class +=3D 2; > >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /* Any speci= al action if a > b? */ > >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > >> -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 match |=3D (a <=3D c && c = <=3D b); > >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (a <=3D c && c <=3D b) > >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 match =3D true; > >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } while ((a =3D *class++) !=3D ']'); > >>=20 > >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (match =3D=3D inverted) > >=20 > > But if we're concerned about bool abuse, what's this? > >=20 > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 bool match =3D false, inverted =3D (*= pat =3D=3D '!'); > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 char const *class =3D pat + inverted; OK, please don't top-post and please do wordwrap the email text. > Hm, I see that, I am sorry about that haha, I tested the functionality > of the code and it seems all fine, if anything major happens, I'll > release another patch fixing this, I am sorry=20 You did't add this. It's existing code which I felt you might want to consider cleaning up.