From nobody Fri Dec 19 16:43:49 2025 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D22F819750B; Fri, 14 Feb 2025 18:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739558809; cv=none; b=HvMuz1KVry/xniejI08/29FbL8BYveNlBBoiLP6LkwrQ6n5LEZrzRw7JsnMjTlAOq6uZF80fjR/qPMSrbI0YglCW7xtvpmM1A+IU1goTAVytnKTF9iWb/JLnjNpo8pYXrxwbXzWY0iN5UbUaJrIbuK1I5yr6nOVt4n2JplEBv+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739558809; c=relaxed/simple; bh=tKW4TH+LAPY6Tur9AlHrWs1vDbIL8qmHHn4fMeFUVzU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DM0RpRAL0R0cChlqk/kqPIP37oBA59EXp2cYalHa0jqKla6eCPRmocidet6mAs6wguhh6gHx4HGPM/J4H1o22gSa7FGACLvs4xE9v24nQs0geePMPnbJNDc38g5fHT2WN0rCx0Ho1aCGqIFQSs3cLQSuxnyayhLDhSssEZ8Rpvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cn19R4Cq; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cn19R4Cq" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-220c665ef4cso36261645ad.3; Fri, 14 Feb 2025 10:46:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739558807; x=1740163607; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3AoyiB+ByqlTcNNpk1JUjsGL3GRg2563aZYap+mUJBM=; b=cn19R4CqUGa1DTSsPiQWi4cVb/3adnsb0CEfnwg8M2mirkrq7fBWg6Tl5J+oH+Hrw2 DqvrPG3zNPdojXS+SyshbroqVKsK3j7O9quRL5AYWcq2BoQHQu9iYQ+FyEHNDqi5cwS0 fj/WoSNXDNi7Jcq+RdZRDA82dAKE+S3ul4zuGk3EpAWIEv6+Okmq2Jgph1Ebsz8kfbdU R7m6RpIHAV8cci9EZeSYZvGnOtplebTqukjn5tKf9C2UKzowRWPN4V8YafKvzMCLXAxW vt45Y8v8iH3lcDhnKIe9gFL1HcNMSYKO8+c2818Iea/MA5PiKPDfVihav2ZUWXWW9MMO 13HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739558807; x=1740163607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3AoyiB+ByqlTcNNpk1JUjsGL3GRg2563aZYap+mUJBM=; b=Ps+BOizma4/qny0IVVgLUZ/W7XmF5zMJAyv+9mCNqQd/LHqzc/Y7W/K8QH7hhZ1FcO 7Y6PwPlnqBiRrd11ASGE5SqlonislPNOeFO0dhN4h1aR//q4NHQBi5AKgwZQBr4mD44p IVsNr59RPpw5yANpdnP6NoPhzARVb0f7eiywJ1Yu9b7YX1B5WELCwTsghzMYMKVc7SiH Q5eLutycaRIlrbStHPkhsCgRL+y9BSwNcdDyYQikDCyRwBya6Nrk3x3o/RF0lo+Gqnsk 52FmIM+uM89uBwabcJQb9XW8dBLGXpy43CcekoTVztPjNvsaop5K0df7vmhn/b7Vaxfo v9hA== X-Forwarded-Encrypted: i=1; AJvYcCWJ1MrtC3i4NfhW9N/VtdnSKYSLiACn7ZexsDx/nITxH4kxZLybynBqp8YwA7bR3b7Vk5N+60kqQta+86Y=@vger.kernel.org, AJvYcCWbjRSstjYdNEq3i2U11Zn6r1Tb9FlBOQnGxEc/oqNQBk1wazFl2/P4P8+xPiAqLIa1DaCJfEdLf3LUZexsQWQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3Ix3aAqMYDHYvEi5qw13xWvpoRHMRtR293kqkD1AC7IGKjS62 6ftDKiasqjHROZeGb74JEysJTRCiuGPE+YQTeDu5nvoGDyA6q+jM X-Gm-Gg: ASbGncv9XzzAgXTZlP3+VrErRoJZQhZCry6VEMYBkYEsmQVGVN7Pz5ufOXAm/kjfLFj nHNiXX/v60RNBqJ115ku86NvBJMkoMI7DLYVYlCCgWhpRX5UjVQjZ0z1gYAzn9KIvbp+fpx2XSn iznD/uMzGCJHJeYvQfrH6+WnDBRQOPrN9tJgN+EgYCFNCYkfFlPzGTQDv9ZYr4YwgxT9hCUfzDV jo0bHWhjStkwmHoKa1SHundd9/XpkWPUFLL1QQlCFDteCixqjPWu4iBLfXszBBVzemCDTdZvy6o Dq/0F4l2ExF/cMADvPc7u5fO X-Google-Smtp-Source: AGHT+IGNJdsTANpgQB9CUn3wHqXnjo+MVrHilYvKJLz9u8VJDAtfjsY4CYzy6l8JTiWrQLPvH4bnMg== X-Received: by 2002:a05:6a00:1488:b0:730:949d:2d32 with SMTP id d2e1a72fcca58-73261799882mr761323b3a.6.1739558806844; Fri, 14 Feb 2025 10:46:46 -0800 (PST) Received: from linuxsimoes.. ([187.120.159.118]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73242546841sm3438637b3a.1.2025.02.14.10.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 10:46:46 -0800 (PST) From: Guilherme Giacomo Simoes To: a.hindborg@kernel.org, alex.gaynor@gmail.com, aliceryhl@google.com, apw@canonical.com, arnd@arndb.de, aswinunni01@gmail.com, axboe@kernel.dk, benno.lossin@proton.me, bhelgaas@google.com, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, dakr@kernel.org, dwaipayanray1@gmail.com, ethan.twardy@gmail.com, fujita.tomonori@gmail.com, gary@garyguo.net, gregkh@linuxfoundation.org, joe@perches.com, lukas.bulwahn@gmail.com, ojeda@kernel.org, pbonzini@redhat.com, tmgross@umich.edu, walmeida@microsoft.com Cc: trintaeoitogc@gmail.com, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Miguel Ojeda Subject: [PATCH V2 1/2] rust: module: change author to be a array Date: Fri, 14 Feb 2025 15:45:49 -0300 Message-Id: <20250214184550.120775-2-trintaeoitogc@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250214184550.120775-1-trintaeoitogc@gmail.com> References: <20250214184550.120775-1-trintaeoitogc@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In the module! macro, the author field has a string type. Once that the modules can has more than one author, this is impossible in the current scenary. Change the author field for accept a array string type and enable module creations with more than one author. In modules that use the author field, change its value to a string array. Suggested-by: Miguel Ojeda Link: https://github.com/Rust-for-Linux/linux/issues/244 Signed-off-by: Guilherme Giacomo Simoes --- drivers/block/rnull.rs | 2 +- rust/kernel/net/phy.rs | 4 ++-- rust/kernel/pci.rs | 2 +- rust/macros/lib.rs | 4 ++-- rust/macros/module.rs | 8 +++++--- samples/rust/rust_driver_pci.rs | 2 +- samples/rust/rust_minimal.rs | 2 +- samples/rust/rust_misc_device.rs | 2 +- samples/rust/rust_print_main.rs | 2 +- 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/block/rnull.rs b/drivers/block/rnull.rs index ddf3629d8894..cb133993f27f 100644 --- a/drivers/block/rnull.rs +++ b/drivers/block/rnull.rs @@ -27,7 +27,7 @@ module! { type: NullBlkModule, name: "rnull_mod", - author: "Andreas Hindborg", + author: ["Andreas Hindborg"], description: "Rust implementation of the C null block driver", license: "GPL v2", } diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs index bb654a28dab3..b179ac3a8d00 100644 --- a/rust/kernel/net/phy.rs +++ b/rust/kernel/net/phy.rs @@ -790,7 +790,7 @@ const fn as_int(&self) -> u32 { /// DeviceId::new_with_driver::() /// ], /// name: "rust_sample_phy", -/// author: "Rust for Linux Contributors", +/// author: ["Rust for Linux Contributors"], /// description: "Rust sample PHYs driver", /// license: "GPL", /// } @@ -819,7 +819,7 @@ const fn as_int(&self) -> u32 { /// module! { /// type: Module, /// name: "rust_sample_phy", -/// author: "Rust for Linux Contributors", +/// author: ["Rust for Linux Contributors"], /// description: "Rust sample PHYs driver", /// license: "GPL", /// } diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index 4c98b5b9aa1e..1218eaa7be02 100644 --- a/rust/kernel/pci.rs +++ b/rust/kernel/pci.rs @@ -103,7 +103,7 @@ extern "C" fn remove_callback(pdev: *mut bindings::pci_= dev) { /// kernel::module_pci_driver! { /// type: MyDriver, /// name: "Module name", -/// author: "Author name", +/// author: ["Author name"], /// description: "Description", /// license: "GPL v2", /// } diff --git a/rust/macros/lib.rs b/rust/macros/lib.rs index d61bc6a56425..8d74e18caf96 100644 --- a/rust/macros/lib.rs +++ b/rust/macros/lib.rs @@ -36,7 +36,7 @@ /// module!{ /// type: MyModule, /// name: "my_kernel_module", -/// author: "Rust for Linux Contributors", +/// author: ["Rust for Linux Contributors"], /// description: "My very own kernel module!", /// license: "GPL", /// alias: ["alternate_module_name"], @@ -69,7 +69,7 @@ /// module!{ /// type: MyDeviceDriverModule, /// name: "my_device_driver_module", -/// author: "Rust for Linux Contributors", +/// author: ["Rust for Linux Contributors"], /// description: "My device driver requires firmware", /// license: "GPL", /// firmware: ["my_device_firmware1.bin", "my_device_firmware2.bin"], diff --git a/rust/macros/module.rs b/rust/macros/module.rs index cdf94f4982df..09265d18b44d 100644 --- a/rust/macros/module.rs +++ b/rust/macros/module.rs @@ -94,7 +94,7 @@ struct ModuleInfo { type_: String, license: String, name: String, - author: Option, + author: Option>, description: Option, alias: Option>, firmware: Option>, @@ -135,7 +135,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self { match key.as_str() { "type" =3D> info.type_ =3D expect_ident(it), "name" =3D> info.name =3D expect_string_ascii(it), - "author" =3D> info.author =3D Some(expect_string(it)), + "author" =3D> info.author =3D Some(expect_string_array(it)= ), "description" =3D> info.description =3D Some(expect_string= (it)), "license" =3D> info.license =3D expect_string_ascii(it), "alias" =3D> info.alias =3D Some(expect_string_array(it)), @@ -184,7 +184,9 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream { =20 let mut modinfo =3D ModInfoBuilder::new(info.name.as_ref()); if let Some(author) =3D info.author { - modinfo.emit("author", &author); + for author in author { + modinfo.emit("author", &author); + } } if let Some(description) =3D info.description { modinfo.emit("description", &description); diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci= .rs index 1fb6e44f3395..5784677c797b 100644 --- a/samples/rust/rust_driver_pci.rs +++ b/samples/rust/rust_driver_pci.rs @@ -104,7 +104,7 @@ fn drop(&mut self) { kernel::module_pci_driver! { type: SampleDriver, name: "rust_driver_pci", - author: "Danilo Krummrich", + author: ["Danilo Krummrich"], description: "Rust PCI driver", license: "GPL v2", } diff --git a/samples/rust/rust_minimal.rs b/samples/rust/rust_minimal.rs index 4aaf117bf8e3..74279c3bd039 100644 --- a/samples/rust/rust_minimal.rs +++ b/samples/rust/rust_minimal.rs @@ -7,7 +7,7 @@ module! { type: RustMinimal, name: "rust_minimal", - author: "Rust for Linux Contributors", + author: ["Rust for Linux Contributors"], description: "Rust minimal sample", license: "GPL", } diff --git a/samples/rust/rust_misc_device.rs b/samples/rust/rust_misc_devi= ce.rs index 40ad7266c225..e840c12005cc 100644 --- a/samples/rust/rust_misc_device.rs +++ b/samples/rust/rust_misc_device.rs @@ -116,7 +116,7 @@ module! { type: RustMiscDeviceModule, name: "rust_misc_device", - author: "Lee Jones", + author: ["Lee Jones"], description: "Rust misc device sample", license: "GPL", } diff --git a/samples/rust/rust_print_main.rs b/samples/rust/rust_print_main= .rs index 7e8af5f176a3..f6d51b0884fb 100644 --- a/samples/rust/rust_print_main.rs +++ b/samples/rust/rust_print_main.rs @@ -8,7 +8,7 @@ module! { type: RustPrint, name: "rust_print", - author: "Rust for Linux Contributors", + author: ["Rust for Linux Contributors"], description: "Rust printing macros sample", license: "GPL", } --=20 2.34.1 From nobody Fri Dec 19 16:43:49 2025 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E131193435; Fri, 14 Feb 2025 18:46:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739558818; cv=none; b=drte6PO7kNMQsqBy4GJS5iyPbnL46yrGuW9nGwG/E7mHu+p427epSUNGwOJK/970TBzlXObkhmnYqNVQENhaqAKOSxiIOg+78nlDkFyGFUDmLQjySfc/rd3ESCC/erEs2xgHROCK9ZDSbNgl4R2LgwfxmvaCI+/fjOxhzhxsxkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739558818; c=relaxed/simple; bh=j76Dso+lvHql/WnntoLkEASAw1W6oVMPhEsmqfGq3e4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XwmkltR6kfedYQH8B6AfzUbBADkZsqztAr6DZDawycDhO7evXWF9b9g2SA9ay02j5q5oeSr7CWOt1h3lUgfLcResclcXUyxgOjWTsyrMADYJfSiBpPA2E3vULWBHFiloxGxDmrqv8rWx6y3AUr6EDfwuE06k8ZcVBe83CnJ1myQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZL5QjXD3; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZL5QjXD3" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-220ecbdb4c2so32353055ad.3; Fri, 14 Feb 2025 10:46:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739558816; x=1740163616; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tvtBYB/97otGJ2jpua78++vpzqj8t8PaL+yJVTrzLLg=; b=ZL5QjXD35WTmknUvV/lBmbbKLOEcjXBKlopN26CNIU07oZnZkuH6rpdtwot7aCwYER 7tQeEvoS4IP0G4mRmruIvhoKtlUIC5AzEGA+ZN9fz7WIzDe2ns/yCM79z/j9B11yhlkn 1hq8nOjPKV+u2CL1t4Ogsfie5/hhMLGtIC128sQDpszTTHy1okob+7wkUvUV7JB/N+0h Cb2t4sgKETHUb083uE1zVPzUt02BWRm5f3seV1Tr0WtP5U6TJ+NxbWuBtgy8o4T6a/v6 C4b+oSi1exlrW8EjB7YNeoIP3YfgYM69AcPR0TeNwObpKegBm1EpD6dYfNCc4CDUQ94/ CMEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739558816; x=1740163616; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tvtBYB/97otGJ2jpua78++vpzqj8t8PaL+yJVTrzLLg=; b=Dtmb1WeBMwzKnChEX7ExrNyuG5UWdpaKw9/xMyNHRlFvWaa4mqXdiZWT9j5OwCeTKL N/MMlZDrKXwD3y/KtdqucLQ/aMfQnB5cyKYXbaWk85gu7g1caPVlIWs6QFFDXj7gDYj7 AkCFw1t0P0FpNV3Ae1ri0RIECdtSzju0TaeoZHJRJ37Pq4S1SH+TCV5RBILzionaOuZ5 NmiP6+xw+qfTfmVHBvvYU5qWJ6Z34vSj4jyovGqZa4NRRFYeLLzCSvJ7zjOI5wBZWYbx NAl6DxH6jpF3DNXuIQxQrmEqsnqTio5RcyQgbuC6jX3cP1sUe7Ql9BCvIrfx0F4C8Z8G HDDw== X-Forwarded-Encrypted: i=1; AJvYcCV8S8hDKtbO9smPDUNxA8N0E6dumhXGyHDROeHxKsz3iGWTwgV2htmczBDBkXKulTj2trZx03s015AEXkw=@vger.kernel.org, AJvYcCVb28DEgLaSOAtTv5o/P2OJlNBo5jk0MJ6lScNjl55Jt/gKHUrPiUw7ymZ2FQZR1q9DyrRASnOX9BZK5yH7/0M=@vger.kernel.org X-Gm-Message-State: AOJu0YzNV12pqGe7gSSNO5JuqxlWKZFNeTRct5CvzIvv1wYC45I4OF4O 8KT6Cy/xQMqP9Ewu9balcSulKV4Ziinz9mhgfYQdD1ETiXwaLCraslpra2xx X-Gm-Gg: ASbGnctqlhLwiNqTjNsN6kPHsW3L3HPk/QcIv9Jfayfi0ru69TPvbwc0j0i8r5jb7RT 247nZNvuVxdQSVDMErYm2wn1yd11EwyeS85OjUR5Xp846+NVpdJGfeGjOwT+FomopCVcBKhHQaP ZeTUhimOua0DxT5Ba6ZQHR0pzrzjDZ4ixAQrjNXasYnks2/kaaJHK7BvVceSMmM0iEYOQDUTgmW nniqnQGGCWKFfUi2xs2fjC/C4iv5xfhhM2cNHZKKnEJJjfYR6dv1RKBYo3tuiovksb2epp6aGIV 9f2aqJUgc4jM3cK092zNwHOD X-Google-Smtp-Source: AGHT+IHWuC7B5WLE6Hp5I9ovuYQpYv6XpWpsy4TGYkIc55ebZe9RLGeMelJrtLnj/OCLbRkeImUwIg== X-Received: by 2002:a05:6a21:b97:b0:1ed:86cd:d6f8 with SMTP id adf61e73a8af0-1ee8cb0c97cmr1046214637.3.1739558816574; Fri, 14 Feb 2025 10:46:56 -0800 (PST) Received: from linuxsimoes.. ([187.120.159.118]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73242546841sm3438637b3a.1.2025.02.14.10.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 10:46:56 -0800 (PST) From: Guilherme Giacomo Simoes To: a.hindborg@kernel.org, alex.gaynor@gmail.com, aliceryhl@google.com, apw@canonical.com, arnd@arndb.de, aswinunni01@gmail.com, axboe@kernel.dk, benno.lossin@proton.me, bhelgaas@google.com, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, dakr@kernel.org, dwaipayanray1@gmail.com, ethan.twardy@gmail.com, fujita.tomonori@gmail.com, gary@garyguo.net, gregkh@linuxfoundation.org, joe@perches.com, lukas.bulwahn@gmail.com, ojeda@kernel.org, pbonzini@redhat.com, tmgross@umich.edu, walmeida@microsoft.com Cc: trintaeoitogc@gmail.com, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 2/2] checkpatch: throw error in malformed arrays Date: Fri, 14 Feb 2025 15:45:50 -0300 Message-Id: <20250214184550.120775-3-trintaeoitogc@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250214184550.120775-1-trintaeoitogc@gmail.com> References: <20250214184550.120775-1-trintaeoitogc@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In module! macro, some fields have a string array type, and we need a check for guarantee a good formatation. Check if the current line contains one of these keys that must be a string array and if so, make a regex for check if contains more than one value in array, if yes, the array should be in vertical. If array have only one value, so the array can be in the same line. Signed-off-by: Guilherme Giacomo Simoes --- scripts/checkpatch.pl | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7b28ad331742..89fbec713bf3 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2775,6 +2775,9 @@ sub process { $realcnt =3D 0; $linenr =3D 0; $fixlinenr =3D -1; + + my %array_parse_module; + foreach my $line (@lines) { $linenr++; $fixlinenr++; @@ -3567,6 +3570,46 @@ sub process { # ignore non-hunk lines and lines being removed next if (!$hunk_line || $line =3D~ /^-/); =20 +# check if arrays has more than one value in the same line + my $inline =3D 0; + my $key =3D ""; + my $add_line =3D $line =3D~ /^\+/; + + if ($line =3D~ /\s*.*\b(author|alias|firmware)\s*:\s*\[/) { + $inline =3D 1; + $array_parse_module{$1} =3D 1; + } + + my @keys =3D keys %array_parse_module; + if (@keys) { + $key =3D $keys[0]; + } + + if ($add_line && $key) { + my $herevet =3D "\n$here\n" . cat_vet($rawline) . "\n"; + + my $counter =3D () =3D $line =3D~ /"/g; + my $more_than_one =3D $counter > 2; + if ($more_than_one) { + WARN("ARRAY_MODULE_MACRO", + "Prefere one value per line$herevet"); + } elsif ($inline && $line !~ /\]/ && $line !~ /,/ && $line =3D~ /"/) { + WARN("ARRAY_MODULE_MACRO", + "Prefere declare ] in the same line$herevet"); + } elsif (!$inline && $line =3D~ /\]/ && $line =3D~ /\"/) { + WARN("ARRAY_MODULE_MACRO", + "Prefere a new line after last value and before ]$herevet"); + } elsif ($inline && $line =3D~ /,/ && $line !~ /\]/) { + WARN("ARRAY_MODULE_MACRO", + "Prefere a new line after [$herevet"); + } + } + + #END OF ANALYZE FIELD + if ($line =3D~ /\]/) { + delete $array_parse_module{$key}; + } + #trailing whitespace if ($line =3D~ /^\+.*\015/) { my $herevet =3D "$here\n" . cat_vet($rawline) . "\n"; --=20 2.34.1