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 DABA3296BD1 for ; Sun, 1 Mar 2026 19:25:43 +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=1772393143; cv=none; b=ql7jkiuTNUFs7fokuGBMdBE5ZvkOnQEisXz1MVPGNu30wEXmJg/yYbbT9FaLb68nS7JghEA9WFOPSJMNv9sEeFP5JLCMiTtgkNhradzG50rABMbVS3Y6BgHhPLNmraswMIjSRq9od0Dnv98Ady4ZUW+jklSu+4DeE/8boJRdOuw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772393143; c=relaxed/simple; bh=5Hgqvqq5mVntVfYN8M+lBM3iTzo9JRHFCLAq8KEVytg=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=TCHsgGk9LP6M/cYD4FXDCQia9sVpwY7WGF5q//vnsxuU4udq0DHUDmandsYyvHAhiVZQzxBz9jTgKM1W4MOhxF0xKng1SRBAvR4qJXjAmpHIw/fjzNIv0ngj9ngT4gLBtthEq1nQ9KMD0BHy6GWFUQTtRiFK+HRw4OI2DPzNYEA= 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=HaB7s+8c; 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="HaB7s+8c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78EBAC116C6; Sun, 1 Mar 2026 19:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1772393143; bh=5Hgqvqq5mVntVfYN8M+lBM3iTzo9JRHFCLAq8KEVytg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=HaB7s+8cK3PyPdeHH35PQHUOJb3VZhXIM/E8+Lv1BnwF4QCs2X099bVEBhyIftA+g xGFCCDC9e5nzrQopdf9VFmZznnfwW+xXwxtViEakfkG+Kf1lg4d2LGiDMNZlg2JWtT PmM5gYKEO+hDf+mzqgVpeXe6P7w6f7j9CGtAABZQ= Date: Sun, 1 Mar 2026 11:25:42 -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: <20260301112542.0d915c2388febccf0294b880@linux-foundation.org> In-Reply-To: <20260301152143.2572137-2-objecting@objecting.org> References: <20260301152143.2572137-1-objecting@objecting.org> <20260301152143.2572137-2-objecting@objecting.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=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 1 Mar 2026 15:21:42 +0000 Josh Law wrote: > Using bitwise OR (|=) on a boolean variable is valid C, but replacing it with a direct logical assignment makes the intent clearer and appeases strict static analysis tools. > Fair enough. > --- a/lib/glob.c > +++ b/lib/glob.c > @@ -96,7 +96,8 @@ bool __pure glob_match(char const *pat, char const *str) > class += 2; > /* Any special action if a > b? */ > } > - match |= (a <= c && c <= b); > + if (a <= c && c <= b) > + match = true; > } while ((a = *class++) != ']'); > > if (match == inverted) But if we're concerned about bool abuse, what's this? bool match = false, inverted = (*pat == '!'); char const *class = pat + inverted;