From patchwork Sat Sep 16 18:21:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 141104 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1850763vqi; Sat, 16 Sep 2023 14:20:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWLFQLmMhC3q+drKnrw7IICA61bkT2CG/p6o9I4/uYrEA1ncO6i0BMsFBdo3Ysy50gi+M7 X-Received: by 2002:a05:6a20:8f29:b0:14c:a2e1:65ec with SMTP id b41-20020a056a208f2900b0014ca2e165ecmr7166959pzk.38.1694899232921; Sat, 16 Sep 2023 14:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694899232; cv=none; d=google.com; s=arc-20160816; b=qjKsGT4imYqN8k3DTjRbiHFKha8RboDZibnieK4w5I9Dj5YbTbmO8VGBWtyD47WrS4 FkjlqvOPnqDW7QoWEmLfB0G1PyFgRx+eShORtcny+HWNzx5tcN4nB/bH/Q2e05JtKOz1 Jt7P6NKKnU34wmGcyTyFLTdwlHO3MHV12dbBEPeZuY+6I5Ou7axygVG/Mpmvn1KU1dAG TWR/fWSInIrSkN8ga2Jx8s55CvdO0zfOWqn1yLy/+s97q6AVT18FEslGmyPX2fRgSa+C 8HjX+Zjy5yd190v2W8q7inFXfkZRAbc8LA0VDSFByXbmi3OxbWiPc5EIM+Os1rNIhkOH XhNQ== 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 Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id dc5-20020a056a0035c500b0069023afd0d1si5350451pfb.329.2023.09.16.14.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 14:20:32 -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 60CAE83D02EC; Sat, 16 Sep 2023 11:27:23 -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 S233268AbjIPSVr (ORCPT + 29 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-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:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777230658303883146 X-GMAIL-MSGID: 1777230658303883146 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)