From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E4D2C88CB2 for ; Mon, 12 Jun 2023 21:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238884AbjFLVEr (ORCPT ); Mon, 12 Jun 2023 17:04:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238598AbjFLVEW (ORCPT ); Mon, 12 Jun 2023 17:04:22 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 221C6212F for ; Mon, 12 Jun 2023 14:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686603666; x=1718139666; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=mrVl+bp40EUDrLYzLK2irxG+GLfNeJEEGBShFcfU674=; b=lQ1wqYZEwhD1uj7rq4CoSoQRZTT9ZOCMvT1IzI0d0DGyhdJy9XkS84zC i+PaI7m9LE2HyyPE8Ck17Pq33DB+3Ah1RZh7UBiVk6yQW82WNm+XokjDa XtWYWwg1kosoJoMwY3K/Gu47RSSXJVuSuBybijd0o+ZVrYVyapeNJI7br FGjMQM0qtswEQ+AILhgESSyLHiwzv08ycNqMzqDxrcNDL47nBXDJ0ALoV T/GDUvy81gPGyV75A/14ruFw80UDNcp+1L4vCRc3YwK/Bz/J79os6VQgg GZZ5iopb8bybSE83MOkr0/3ykm3EXHEOV7a+CPU6n0KpD/RZ4r8gNSKRy Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="444538187" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="444538187" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 14:00:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="824110378" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="824110378" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga002.fm.intel.com with ESMTP; 12 Jun 2023 14:00:47 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1q8oeb-003Ix8-0d; Tue, 13 Jun 2023 00:00:45 +0300 Date: Tue, 13 Jun 2023 00:00:44 +0300 From: Andy Shevchenko To: Demi Marie Obenour Cc: Alexey Dobriyan , linux-kernel@vger.kernel.org, Rasmus Villemoes , Hans de Goede , Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Lee Jones , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Petr Mladek , Steven Rostedt , Sergey Senozhatsky Subject: Re: [PATCH v3 0/4] Make sscanf() stricter Message-ID: References: <6ab6adce-2318-4ae6-bde6-4317485639fd@p183> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 12, 2023 at 04:25:01PM -0400, Demi Marie Obenour wrote: > On Mon, Jun 12, 2023 at 02:59:38PM +0300, Alexey Dobriyan wrote: > > > + bool _placeholder; > > > + return simple_strntoull(cp, INT_MAX, endp, base, &_placeholder); > > > > This can be done without introducing dummy variables: > > > > void f(bool *b) > > { > > } > > > > f((bool[1]){}); > > This is more consise, but (at least to me) significantly less readable. > > > > > lib/vsprintf.c:3727:26: error: unknown conversion type character ‘!’ in format [-Werror=format=] > > > So NAK. > > > > Yeah, ! should go after format specifier like it does for %p. > > I hadn't considered that. Is the typical approach in Linux to use e.g. > %d%[!] if one wants a literal '!'? It might be that the cleanest way we have is to create %p-like extensions to sscanf(). %p takes alnum as parameter and that is usually works since it makes a little sense to attach alnum suffix to the pointer. (I don't like to have %dX, where X is alnum as we expanding our hack to something which people don't expect to be altered even in the kernelm, you may refer to the discussion about %de for printing errors) -- With Best Regards, Andy Shevchenko