Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5490601rdb; Sat, 16 Sep 2023 21:50:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYDRV6phb9Weq3TApqHmSl2fbZoBBkxAEpn3ssH4EoH1OfFlJYjrSZEptP241I7DnajlWb X-Received: by 2002:a05:6e02:f82:b0:345:3378:4251 with SMTP id v2-20020a056e020f8200b0034533784251mr7023193ilo.23.1694926201544; Sat, 16 Sep 2023 21:50:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694926201; cv=none; d=google.com; s=arc-20160816; b=TlnoqjY8+wshfRUaEwPDAnvd0v3wd/ocfjjNKDredEe8UrdwsC2rQG32UeAgRnDYkQ SjFjFBkII19y9w+/bwGaJxTITmnS3phAD4qgpa4ZFf+TxJq3ZADPBemqT/zAMU4ojxqu gkhyjY2rfZ0/g7SVQNX2GWNClxbmL/lfR/LUWDubPAKSHnmhcg5twmpWDhalqgjJKLEB hgsCe7z3IJsEQ8Af0OO5hG5jf+8/BjSBk9NTT4OXiacbWAJxGHpqcABGv53wEMG9HdMa YIhm03goGJdN/cwIrQoRxK3c9Z0d2qPbyh23bXh9huK0lpQUGT8/oRmi/wwy/38hqaJi L6Jg== 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:cc:to:from:date:dkim-signature; bh=FTdyb3zvatPdaFJlPoz0gdD5HKKgZ3y8QEX/wWGYg5M=; fh=vAL//rX5bq0IQHDOKctX+WpCcqgiwHLa990iR8X0E5w=; b=WCRhkcUiuaMY+T+4jKGdA1n4keLLNpc9niEoej/1d5/lvq5U45XgQFFMY4OYPNBh54 umzilLaNZw8yR4SmEE1VQrCyE0lFwjbwwmuge4NlUGpLPXmwUeXzuUii1n1Gja0cJfI5 d6j+aKmUXHOpDjTRqcSBN0Xiqhm2gMj0COiv6MF0gOYOMnWUFrt7QUOmt9OmFYHOYsci oOJWP2DNpRMvLiS+XK4uwqW44QFz3lH7kQP9DU20vZtsjI69aDlcQBZtqGguXLvppDts +qkxuM+qHOLqyu0djY3i95bGBEcoIrY4G1B3wq8gr8mPhZhvAP7xnL0UUuUsdaOrO9lV 2GBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QpkTPR8X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id x64-20020a636343000000b0057416a797dasi5967342pgb.734.2023.09.16.21.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 21:50:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QpkTPR8X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id D6B5183D02DF; Sat, 16 Sep 2023 11:27:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231954AbjIPSVr (ORCPT + 99 others); Sat, 16 Sep 2023 14:21:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233902AbjIPSVk (ORCPT ); Sat, 16 Sep 2023 14:21:40 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3BD8CE6 for ; Sat, 16 Sep 2023 11:21:35 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9adb9fa7200so622079366b.0 for ; Sat, 16 Sep 2023 11:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694888494; x=1695493294; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=FTdyb3zvatPdaFJlPoz0gdD5HKKgZ3y8QEX/wWGYg5M=; b=QpkTPR8XiGZ29rzL5rat9BsWqhdJz5cSPb60q9FUdHVTNF4YUcDOXyRka/Fqga8OeM qHXYKEp0TA8nSlwW5K2rTiDAFFr97J+i4yJRcOyf71C0yIT9lBE8/EneCl/37UKRDM3O qv6o9dJisXVXONmdZPoSSdlBsrx8KlvE+euGdg8V9RXpgJO64KIW1e+x6u1gm5PPICzb HX9RezJIB8HrU5iQiZDO+r9dNNapnPySW5M2eBXoygPTEtX9GegagkSQxlJjpPbyI6wP CWRGMYIgHc6OWA4An1myijlxxhx87HdeAbtR/96aFo7RwSkkkcdtUfIYH9BleP+5Qzs4 O6TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694888494; x=1695493294; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FTdyb3zvatPdaFJlPoz0gdD5HKKgZ3y8QEX/wWGYg5M=; b=wFsG/w7NTy6yYGY8eoWdfcYV2Y7XU2fogTeQcxBzoTYZkVnM8G/NwRR+CYJbD0YQ0t XCzL2xM8QAhbx8LOi6XmltBEUzyw5JH9h4IAKtV9MHy9wbrXmiSQ2+OqEOef+L0ipg/4 JYeM/90lc+UGAR5tMQl9p7CP4ZI2alc149Fp64I9SetF+V8jKtB5pdAjxR5bEz3uMydC 1cMHgfE4It8uxSlqHU9DhRgyb7VX3F3axCgfFBTOreuWD1R/0hUrDAi7XLt7DWQj7IhG qfzUyFpI2MmB1FtpbJbOh+EHziQsF4mCAdUsQwmoW7IgnIiBtcUylff83PVyLEusxW7Q 0C0g== X-Gm-Message-State: AOJu0Ywn32Yg34DnJP1cgDtBOuVBcsz7v/yJ4MO/HGG11DFEy5MfmqZm R+LRhlxsvPpGiEsAFrKN/rVyF4hKfg== X-Received: by 2002:a17:906:5a5f:b0:9a5:9305:83fb with SMTP id my31-20020a1709065a5f00b009a5930583fbmr6797477ejc.34.1694888493805; Sat, 16 Sep 2023 11:21:33 -0700 (PDT) Received: from p183 ([46.53.254.83]) by smtp.gmail.com with ESMTPSA id rl20-20020a1709076c1400b009adc81c0c7esm2830391ejc.107.2023.09.16.11.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 11:21:33 -0700 (PDT) Date: Sat, 16 Sep 2023 21:21:31 +0300 From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: Kees Cook , Thomas Gleixner , linux-kernel@vger.kernel.org, Takashi Iwai Subject: [PATCH] extract and use FILE_LINE macro Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sat, 16 Sep 2023 11:27:03 -0700 (PDT) Extract nifty FILE_LINE useful for printk style debugging: printk("%s\n", FILE_LINE); It should not be used en mass probably because __FILE__ string literals can be merged while FILE_LINE's won't. But for debugging it is what the doctor ordered. Don't add leading and trailing underscores, they're painful to type. Trust me, I've tried both versions. Signed-off-by: Alexey Dobriyan --- include/linux/fortify-string.h | 2 +- include/linux/stringify.h | 2 ++ include/linux/timer.h | 3 +-- sound/pci/asihpi/hpidebug.h | 9 ++++----- 4 files changed, 8 insertions(+), 8 deletions(-) --- a/include/linux/fortify-string.h +++ b/include/linux/fortify-string.h @@ -643,7 +643,7 @@ __FORTIFY_INLINE bool fortify_memcpy_chk(__kernel_size_t size, __q_size_field, #op), \ #op ": detected field-spanning write (size %zu) of single %s (size %zu)\n", \ __fortify_size, \ - "field \"" #p "\" at " __FILE__ ":" __stringify(__LINE__), \ + "field \"" #p "\" at " FILE_LINE, \ __p_size_field); \ __underlying_##op(p, q, __fortify_size); \ }) --- a/include/linux/stringify.h +++ b/include/linux/stringify.h @@ -9,4 +9,6 @@ #define __stringify_1(x...) #x #define __stringify(x...) __stringify_1(x) +#define FILE_LINE __FILE__ ":" __stringify(__LINE__) + #endif /* !__LINUX_STRINGIFY_H */ --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -77,8 +77,7 @@ struct timer_list { .entry = { .next = TIMER_ENTRY_STATIC }, \ .function = (_function), \ .flags = (_flags), \ - __TIMER_LOCKDEP_MAP_INITIALIZER( \ - __FILE__ ":" __stringify(__LINE__)) \ + __TIMER_LOCKDEP_MAP_INITIALIZER(FILE_LINE) \ } #define DEFINE_TIMER(_name, _function) \ --- a/sound/pci/asihpi/hpidebug.h +++ b/sound/pci/asihpi/hpidebug.h @@ -29,16 +29,15 @@ enum { HPI_DEBUG_LEVEL_ERROR = 0, /* always log errors */ the start of each message, eg see linux kernel hpios.h */ #ifdef SOURCEFILE_NAME +#undef FILE_LINE #define FILE_LINE SOURCEFILE_NAME ":" __stringify(__LINE__) " " -#else -#define FILE_LINE __FILE__ ":" __stringify(__LINE__) " " #endif #define HPI_DEBUG_ASSERT(expression) \ do { \ if (!(expression)) { \ printk(KERN_ERR FILE_LINE \ - "ASSERT " __stringify(expression)); \ + " ASSERT " __stringify(expression)); \ } \ } while (0) @@ -46,7 +45,7 @@ enum { HPI_DEBUG_LEVEL_ERROR = 0, /* always log errors */ do { \ if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \ printk(HPI_DEBUG_FLAG_##level \ - FILE_LINE __VA_ARGS__); \ + FILE_LINE " " __VA_ARGS__); \ } \ } while (0) @@ -70,7 +69,7 @@ void hpi_debug_data(u16 *pdata, u32 len); do { \ if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \ hpi_debug_message(phm, HPI_DEBUG_FLAG_##level \ - FILE_LINE __stringify(level)); \ + FILE_LINE " " __stringify(level)); \ } \ } while (0)