linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/15] magic-number.rst funeral rites
@ 2022-11-11  1:13 Ahelenia Ziemiańska
  2022-11-11  1:13 ` [PATCH v3 01/15] hamradio: baycom: remove BAYCOM_MAGIC Ahelenia Ziemiańska
                   ` (14 more replies)
  0 siblings, 15 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:13 UTC (permalink / raw)
  Cc: Andrew Morton, Kees Cook, coda, codalist, linux-arm-kernel,
	linux-doc-tw-discuss, linux-doc, linux-fsdevel, linux-hams,
	linux-kernel, linux-mips, linux-scsi, netdev, x86

[-- Attachment #1: Type: text/plain, Size: 4540 bytes --]

This is a follow-up for the 18+1-patch series (
https://lore.kernel.org/linux-kernel/8389a7b85b5c660c6891b1740b5dacc53491a41b.1663280877.git.nabijaczleweli@nabijaczleweli.xyz/
https://lore.kernel.org/linux-kernel/20220927003727.slf4ofb7dgum6apt@tarta.nabijaczleweli.xyz/
) I sent in September, and the same reasoning applies:

The entire file blames back to the start of git
(minus whitespace from the RST translation and a typo fix):
  * there are changelog comments for March 1994 through to Linux 2.5.74
  * struct tty_ldisc is two pointers nowadays, so naturally no magic
  * GDA_MAGIC is defined but unused, and it's been this way
    since start-of-git
  * M3_CARD_MAGIC isn't defined, because
    commit d56b9b9c464a ("[PATCH] The scheduled removal of some OSS
    drivers") removed the entire driver in 2006
  * CS_CARD_MAGIC likewise since
    commit b5d425c97f7d ("more scheduled OSS driver removal") in 2007
  * KMALLOC_MAGIC and VMALLOC_MAGIC were removed in
    commit e38e0cfa48ac ("[ALSA] Remove kmalloc wrappers"),
    six months after start of git
  * SLAB_C_MAGIC has never even appeared in git
    (removed in 2.4.0-test3pre6)
  * &c., &c., &c.

magic-number.rst is a low-value historial relic at best and misleading
cruft at worst.

This latter half cleans out the remaining entries (either by recognising
that they aren't actually magic numbers or by cutting them out entirely)
and inters the file.

amd64 allyesconfig builds; this largely touches code that would be
exceedingly expensive to test (and largely untouched since the git
import), but is very receptive to static analysis.

v2:
  Messages restyled
  Moved printk() in synclink_cs.c became pr_warn
  (__func__ instead of prescribed hard function name per checkpatch.pl)

v3:
  7/15 no longer cleans out the header that defines NMI_MAGIC

Ahelenia Ziemiańska (15):
  hamradio: baycom: remove BAYCOM_MAGIC
  hamradio: yam: remove YAM_MAGIC
  pcmcia: synclink_cs: remove MGSLPC_MAGIC
  pcmcia: synclink_cs: remove dead paranoia_check, warn for missing line
  coda: remove CODA_MAGIC
  Documentation: remove PG_MAGIC (not a magic number)
  Documentation: remove NMI_MAGIC (not a magic number)
  MIPS: IP27: remove KV_MAGIC
  x86/APM: remove APM_BIOS_MAGIC
  scsi: acorn: remove QUEUE_MAGIC_{FREE,USED}
  hdlcdrv: remove HDLCDRV_MAGIC
  drivers: net: slip: remove SLIP_MAGIC
  fcntl: remove FASYNC_MAGIC
  scsi: ncr53c8xx: replace CCB_MAGIC with bool busy
  Documentation: remove magic-number.rst

 Documentation/process/index.rst               |  1 -
 Documentation/process/magic-number.rst        | 85 -----------------
 .../translations/it_IT/process/index.rst      |  1 -
 .../it_IT/process/magic-number.rst            | 91 -------------------
 .../translations/zh_CN/process/index.rst      |  1 -
 .../zh_CN/process/magic-number.rst            | 74 ---------------
 .../translations/zh_TW/process/index.rst      |  1 -
 .../zh_TW/process/magic-number.rst            | 77 ----------------
 arch/mips/include/asm/sn/klkernvars.h         |  8 +-
 arch/mips/sgi-ip27/ip27-klnuma.c              |  1 -
 arch/x86/kernel/apm_32.c                      |  9 +-
 drivers/char/pcmcia/synclink_cs.c             | 79 +---------------
 drivers/net/hamradio/baycom_epp.c             | 15 +--
 drivers/net/hamradio/baycom_par.c             |  1 -
 drivers/net/hamradio/baycom_ser_fdx.c         |  3 +-
 drivers/net/hamradio/baycom_ser_hdx.c         |  3 +-
 drivers/net/hamradio/hdlcdrv.c                |  9 +-
 drivers/net/hamradio/yam.c                    |  8 +-
 drivers/net/slip/slip.c                       | 11 +--
 drivers/net/slip/slip.h                       |  4 -
 drivers/scsi/arm/queue.c                      | 21 -----
 drivers/scsi/ncr53c8xx.c                      | 25 ++---
 fs/coda/cnode.c                               |  2 +-
 fs/coda/coda_fs_i.h                           |  2 -
 fs/coda/file.c                                |  1 -
 fs/fcntl.c                                    |  6 --
 include/linux/fs.h                            |  3 -
 include/linux/hdlcdrv.h                       |  2 -
 28 files changed, 29 insertions(+), 515 deletions(-)
 delete mode 100644 Documentation/process/magic-number.rst
 delete mode 100644 Documentation/translations/it_IT/process/magic-number.rst
 delete mode 100644 Documentation/translations/zh_CN/process/magic-number.rst
 delete mode 100644 Documentation/translations/zh_TW/process/magic-number.rst

-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v3 01/15] hamradio: baycom: remove BAYCOM_MAGIC
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
@ 2022-11-11  1:13 ` Ahelenia Ziemiańska
  2022-11-11  1:13 ` [PATCH v3 02/15] hamradio: yam: remove YAM_MAGIC Ahelenia Ziemiańska
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:13 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Thomas Sailer, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Greg Kroah-Hartman, Jiri Slaby, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-hams, netdev

[-- Attachment #1: Type: text/plain, Size: 6828 bytes --]

Before being defanged in v2.6.12-rc1, the magic was validated on each
netdev_priv() invocation; after, it's set exactly once per port on probe
and checked exactly once per port on unload: it's useless. Kill it.

Notably, magic-number.rst has never had the right value for it with the
new-in-Linux-2.1.105 network-based driver, rendering this documentation
worse than useless.

Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst            |  1 -
 .../translations/it_IT/process/magic-number.rst   |  1 -
 .../translations/zh_CN/process/magic-number.rst   |  1 -
 .../translations/zh_TW/process/magic-number.rst   |  1 -
 drivers/net/hamradio/baycom_epp.c                 | 15 ++-------------
 5 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index 64b5948fc1d4..87353e0207c1 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -73,7 +73,6 @@ APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kerne
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
-BAYCOM_MAGIC          0x19730510       baycom_state             ``drivers/net/baycom_epp.c``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index 02eb7eb2448e..a96712bd8a68 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -79,7 +79,6 @@ APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kerne
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
-BAYCOM_MAGIC          0x19730510       baycom_state             ``drivers/net/baycom_epp.c``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 0617ce125e12..44f3a29fce57 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -62,7 +62,6 @@ APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kerne
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
-BAYCOM_MAGIC          0x19730510       baycom_state             ``drivers/net/baycom_epp.c``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index f3f7082e17c6..0fde3183e82a 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -65,7 +65,6 @@ APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kerne
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
-BAYCOM_MAGIC          0x19730510       baycom_state             ``drivers/net/baycom_epp.c``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 791b4a53d69f..8f018703e74d 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -45,13 +45,9 @@
 /* --------------------------------------------------------------------- */
 
 #define BAYCOM_DEBUG
-#define BAYCOM_MAGIC 19730510
 
 /* --------------------------------------------------------------------- */
 
-static const char paranoia_str[] = KERN_ERR 
-	"baycom_epp: bad magic number for hdlcdrv_state struct in routine %s\n";
-
 static const char bc_drvname[] = "baycom_epp";
 static const char bc_drvinfo[] = KERN_INFO "baycom_epp: (C) 1998-2000 Thomas Sailer, HB9JNX/AE4WA\n"
 "baycom_epp: version 0.7\n";
@@ -152,8 +148,6 @@ static struct net_device *baycom_device[NR_PORTS];
  */
 
 struct baycom_state {
-	int magic;
-
         struct pardevice *pdev;
 	struct net_device *dev;
 	unsigned int work_running;
@@ -1210,7 +1204,6 @@ static void __init baycom_epp_dev_setup(struct net_device *dev)
 	 * initialize part of the baycom_state struct
 	 */
 	bc->dev = dev;
-	bc->magic = BAYCOM_MAGIC;
 	bc->cfg.fclk = 19666600;
 	bc->cfg.bps = 9600;
 	/*
@@ -1279,12 +1272,8 @@ static void __exit cleanup_baycomepp(void)
 		struct net_device *dev = baycom_device[i];
 
 		if (dev) {
-			struct baycom_state *bc = netdev_priv(dev);
-			if (bc->magic == BAYCOM_MAGIC) {
-				unregister_netdev(dev);
-				free_netdev(dev);
-			} else
-				printk(paranoia_str, "cleanup_module");
+			unregister_netdev(dev);
+			free_netdev(dev);
 		}
 	}
 	parport_unregister_driver(&baycom_epp_par_driver);
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 02/15] hamradio: yam: remove YAM_MAGIC
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
  2022-11-11  1:13 ` [PATCH v3 01/15] hamradio: baycom: remove BAYCOM_MAGIC Ahelenia Ziemiańska
@ 2022-11-11  1:13 ` Ahelenia Ziemiańska
  2022-11-11  1:13 ` [PATCH v3 03/15] pcmcia: synclink_cs: remove MGSLPC_MAGIC Ahelenia Ziemiańska
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:13 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Jean-Paul Roubelat, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Greg Kroah-Hartman, Jiri Slaby,
	linux-doc, linux-kernel, linux-doc-tw-discuss, linux-hams,
	netdev

[-- Attachment #1: Type: text/plain, Size: 6523 bytes --]

This is checked inconsistently, only in contexts following directly from
the module init, and returns an error to userspace/ignores the condition
entirely, rather than yielding remotely-useful diagnostics.

This is cruft, and we have better debugging tooling nowadays: kill it.

Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst                    | 1 -
 Documentation/translations/it_IT/process/magic-number.rst | 1 -
 Documentation/translations/zh_CN/process/magic-number.rst | 1 -
 Documentation/translations/zh_TW/process/magic-number.rst | 1 -
 drivers/net/hamradio/yam.c                                | 8 +-------
 5 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index 87353e0207c1..a4414b7e15aa 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -76,7 +76,6 @@ MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/p
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
-YAM_MAGIC             0xF10A7654       yam_port                 ``drivers/net/hamradio/yam.c``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index a96712bd8a68..f51c5ef9d93f 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -82,7 +82,6 @@ MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/p
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
-YAM_MAGIC             0xF10A7654       yam_port                 ``drivers/net/hamradio/yam.c``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 44f3a29fce57..3b53bd67e41b 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -65,7 +65,6 @@ MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/p
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
-YAM_MAGIC             0xF10A7654       yam_port                 ``drivers/net/hamradio/yam.c``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index 0fde3183e82a..7d176a87ec3c 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -68,7 +68,6 @@ MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/p
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
-YAM_MAGIC             0xF10A7654       yam_port                 ``drivers/net/hamradio/yam.c``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 2ed2f836f09a..0f43411a6ca5 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -73,7 +73,6 @@ static const char yam_drvinfo[] __initconst = KERN_INFO \
 #define YAM_1200	2
 
 #define NR_PORTS	4
-#define YAM_MAGIC	0xF10A7654
 
 /* Transmitter states */
 
@@ -94,7 +93,6 @@ static const char yam_drvinfo[] __initconst = KERN_INFO \
 #define DEFAULT_PERS	64			/* 0->255 */
 
 struct yam_port {
-	int magic;
 	int bitrate;
 	int baudrate;
 	int iobase;
@@ -604,7 +602,7 @@ static void yam_arbitrate(struct net_device *dev)
 {
 	struct yam_port *yp = netdev_priv(dev);
 
-	if (yp->magic != YAM_MAGIC || yp->tx_state != TX_OFF ||
+	if (yp->tx_state != TX_OFF ||
 	    skb_queue_empty(&yp->send_queue))
 		return;
 	/* tx_state is TX_OFF and there is data to send */
@@ -930,9 +928,6 @@ static int yam_siocdevprivate(struct net_device *dev, struct ifreq *ifr, void __
 	if (copy_from_user(&ioctl_cmd, data, sizeof(int)))
 		return -EFAULT;
 
-	if (yp->magic != YAM_MAGIC)
-		return -EINVAL;
-
 	if (!capable(CAP_NET_ADMIN))
 		return -EPERM;
 
@@ -1079,7 +1074,6 @@ static void yam_setup(struct net_device *dev)
 {
 	struct yam_port *yp = netdev_priv(dev);
 
-	yp->magic = YAM_MAGIC;
 	yp->bitrate = DEFAULT_BITRATE;
 	yp->baudrate = DEFAULT_BITRATE * 2;
 	yp->iobase = 0;
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 03/15] pcmcia: synclink_cs: remove MGSLPC_MAGIC
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
  2022-11-11  1:13 ` [PATCH v3 01/15] hamradio: baycom: remove BAYCOM_MAGIC Ahelenia Ziemiańska
  2022-11-11  1:13 ` [PATCH v3 02/15] hamradio: yam: remove YAM_MAGIC Ahelenia Ziemiańska
@ 2022-11-11  1:13 ` Ahelenia Ziemiańska
  2022-11-11  1:13 ` [PATCH v3 04/15] pcmcia: synclink_cs: remove dead paranoia_check, warn for missing line Ahelenia Ziemiańska
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:13 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Arnd Bergmann, Greg Kroah-Hartman, Jakub Kicinski, Jiri Slaby,
	Ilpo Järvinen, Haowen Bai, linux-doc, linux-kernel,
	linux-doc-tw-discuss

[-- Attachment #1: Type: text/plain, Size: 6471 bytes --]

MGSLPC_PARANOIA_CHECK has never been defined automatically, and in the
context of magic numbers as defined in magic-number.rst, "the tty layer
should not need this".

This is 100% dead cruft, and we have better debugging tooling nowadays:
kill it.

Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst                 |  1 -
 .../translations/it_IT/process/magic-number.rst        |  1 -
 .../translations/zh_CN/process/magic-number.rst        |  1 -
 .../translations/zh_TW/process/magic-number.rst        |  1 -
 drivers/char/pcmcia/synclink_cs.c                      | 10 ----------
 5 files changed, 14 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index a4414b7e15aa..18f8b1e3a993 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -72,7 +72,6 @@ PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/
 APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
-MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index f51c5ef9d93f..827167b18f15 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -78,7 +78,6 @@ PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/
 APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
-MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 3b53bd67e41b..9553475e9867 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -61,7 +61,6 @@ PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/
 APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
-MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index 7d176a87ec3c..8a64f56ae267 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -64,7 +64,6 @@ PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/
 APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
-MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index b2735be81ab2..262f087bfc01 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -137,7 +137,6 @@ struct _input_signal_events {
 typedef struct _mgslpc_info {
 	struct tty_port		port;
 	void *if_ptr;	/* General purpose pointer (used by SPPP) */
-	int			magic;
 	int			line;
 
 	struct mgsl_icount	icount;
@@ -228,8 +227,6 @@ typedef struct _mgslpc_info {
 
 } MGSLPC_INFO;
 
-#define MGSLPC_MAGIC 0x5402
-
 /*
  * The size of the serial xmit buffer is 1 page, or 4096 bytes
  */
@@ -525,7 +522,6 @@ static int mgslpc_probe(struct pcmcia_device *link)
 		return -ENOMEM;
 	}
 
-	info->magic = MGSLPC_MAGIC;
 	tty_port_init(&info->port);
 	info->port.ops = &mgslpc_port_ops;
 	INIT_WORK(&info->task, bh_handler);
@@ -652,8 +648,6 @@ static inline bool mgslpc_paranoia_check(MGSLPC_INFO *info,
 					char *name, const char *routine)
 {
 #ifdef MGSLPC_PARANOIA_CHECK
-	static const char *badmagic =
-		"Warning: bad magic number for mgsl struct (%s) in %s\n";
 	static const char *badinfo =
 		"Warning: null mgslpc_info for (%s) in %s\n";
 
@@ -661,10 +655,6 @@ static inline bool mgslpc_paranoia_check(MGSLPC_INFO *info,
 		printk(badinfo, name, routine);
 		return true;
 	}
-	if (info->magic != MGSLPC_MAGIC) {
-		printk(badmagic, name, routine);
-		return true;
-	}
 #else
 	if (!info)
 		return true;
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 04/15] pcmcia: synclink_cs: remove dead paranoia_check, warn for missing line
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
                   ` (2 preceding siblings ...)
  2022-11-11  1:13 ` [PATCH v3 03/15] pcmcia: synclink_cs: remove MGSLPC_MAGIC Ahelenia Ziemiańska
@ 2022-11-11  1:13 ` Ahelenia Ziemiańska
  2022-11-11  1:13 ` [PATCH v3 05/15] coda: remove CODA_MAGIC Ahelenia Ziemiańska
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:13 UTC (permalink / raw)
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Ilpo Järvinen,
	Johan Hovold, Jiri Slaby, Haowen Bai, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 7319 bytes --]

MGSLPC_PARANOIA_CHECK has never been defined automatically, and devices
with null driver_info can't happen, since we reject the open in that case.

Move the log statement from dead code to the check, and log the state
inconsistency like we do above for the line count ("invalid line #%d.").

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 drivers/char/pcmcia/synclink_cs.c | 69 ++-----------------------------
 1 file changed, 4 insertions(+), 65 deletions(-)

diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 262f087bfc01..5aecb5e5cf18 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -644,25 +644,6 @@ static int mgslpc_resume(struct pcmcia_device *link)
 }
 
 
-static inline bool mgslpc_paranoia_check(MGSLPC_INFO *info,
-					char *name, const char *routine)
-{
-#ifdef MGSLPC_PARANOIA_CHECK
-	static const char *badinfo =
-		"Warning: null mgslpc_info for (%s) in %s\n";
-
-	if (!info) {
-		printk(badinfo, name, routine);
-		return true;
-	}
-#else
-	if (!info)
-		return true;
-#endif
-	return false;
-}
-
-
 #define CMD_RXFIFO      BIT7	// release current rx FIFO
 #define CMD_RXRESET     BIT6	// receiver reset
 #define CMD_RXFIFO_READ BIT5
@@ -694,8 +675,6 @@ static void tx_pause(struct tty_struct *tty)
 	MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
 	unsigned long flags;
 
-	if (mgslpc_paranoia_check(info, tty->name, "tx_pause"))
-		return;
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("tx_pause(%s)\n", info->device_name);
 
@@ -710,8 +689,6 @@ static void tx_release(struct tty_struct *tty)
 	MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
 	unsigned long flags;
 
-	if (mgslpc_paranoia_check(info, tty->name, "tx_release"))
-		return;
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("tx_release(%s)\n", info->device_name);
 
@@ -1476,9 +1453,6 @@ static int mgslpc_put_char(struct tty_struct *tty, unsigned char ch)
 			__FILE__, __LINE__, ch, info->device_name);
 	}
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_put_char"))
-		return 0;
-
 	if (!info->tx_buf)
 		return 0;
 
@@ -1508,9 +1482,6 @@ static void mgslpc_flush_chars(struct tty_struct *tty)
 		printk("%s(%d):mgslpc_flush_chars() entry on %s tx_count=%d\n",
 			__FILE__, __LINE__, info->device_name, info->tx_count);
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_chars"))
-		return;
-
 	if (info->tx_count <= 0 || tty->flow.stopped ||
 	    tty->hw_stopped || !info->tx_buf)
 		return;
@@ -1546,8 +1517,7 @@ static int mgslpc_write(struct tty_struct * tty,
 		printk("%s(%d):mgslpc_write(%s) count=%d\n",
 			__FILE__, __LINE__, info->device_name, count);
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write") ||
-		!info->tx_buf)
+	if (!info->tx_buf)
 		goto cleanup;
 
 	if (info->params.mode == MGSL_MODE_HDLC) {
@@ -1600,9 +1570,6 @@ static unsigned int mgslpc_write_room(struct tty_struct *tty)
 	MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
 	int ret;
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write_room"))
-		return 0;
-
 	if (info->params.mode == MGSL_MODE_HDLC) {
 		/* HDLC (frame oriented) mode */
 		if (info->tx_active)
@@ -1632,9 +1599,6 @@ static unsigned int mgslpc_chars_in_buffer(struct tty_struct *tty)
 		printk("%s(%d):mgslpc_chars_in_buffer(%s)\n",
 			 __FILE__, __LINE__, info->device_name);
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_chars_in_buffer"))
-		return 0;
-
 	if (info->params.mode == MGSL_MODE_HDLC)
 		rc = info->tx_active ? info->max_frame_size : 0;
 	else
@@ -1658,9 +1622,6 @@ static void mgslpc_flush_buffer(struct tty_struct *tty)
 		printk("%s(%d):mgslpc_flush_buffer(%s) entry\n",
 			 __FILE__, __LINE__, info->device_name);
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_buffer"))
-		return;
-
 	spin_lock_irqsave(&info->lock, flags);
 	info->tx_count = info->tx_put = info->tx_get = 0;
 	del_timer(&info->tx_timer);
@@ -1681,9 +1642,6 @@ static void mgslpc_send_xchar(struct tty_struct *tty, char ch)
 		printk("%s(%d):mgslpc_send_xchar(%s,%d)\n",
 			 __FILE__, __LINE__, info->device_name, ch);
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_send_xchar"))
-		return;
-
 	info->x_char = ch;
 	if (ch) {
 		spin_lock_irqsave(&info->lock, flags);
@@ -1704,9 +1662,6 @@ static void mgslpc_throttle(struct tty_struct * tty)
 		printk("%s(%d):mgslpc_throttle(%s) entry\n",
 			 __FILE__, __LINE__, info->device_name);
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_throttle"))
-		return;
-
 	if (I_IXOFF(tty))
 		mgslpc_send_xchar(tty, STOP_CHAR(tty));
 
@@ -1729,9 +1684,6 @@ static void mgslpc_unthrottle(struct tty_struct * tty)
 		printk("%s(%d):mgslpc_unthrottle(%s) entry\n",
 			 __FILE__, __LINE__, info->device_name);
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_unthrottle"))
-		return;
-
 	if (I_IXOFF(tty)) {
 		if (info->x_char)
 			info->x_char = 0;
@@ -2160,9 +2112,6 @@ static int mgslpc_break(struct tty_struct *tty, int break_state)
 		printk("%s(%d):mgslpc_break(%s,%d)\n",
 			 __FILE__, __LINE__, info->device_name, break_state);
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_break"))
-		return -EINVAL;
-
 	spin_lock_irqsave(&info->lock, flags);
 	if (break_state == -1)
 		set_reg_bits(info, CHA+DAFO, BIT6);
@@ -2218,9 +2167,6 @@ static int mgslpc_ioctl(struct tty_struct *tty,
 		printk("%s(%d):mgslpc_ioctl %s cmd=%08X\n", __FILE__, __LINE__,
 			info->device_name, cmd);
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_ioctl"))
-		return -ENODEV;
-
 	if (cmd != TIOCMIWAIT) {
 		if (tty_io_error(tty))
 		    return -EIO;
@@ -2312,9 +2258,6 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
 	MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data;
 	struct tty_port *port = &info->port;
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_close"))
-		return;
-
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
 			 __FILE__, __LINE__, info->device_name, port->count);
@@ -2352,9 +2295,6 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout)
 		printk("%s(%d):mgslpc_wait_until_sent(%s) entry\n",
 			 __FILE__, __LINE__, info->device_name);
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent"))
-		return;
-
 	if (!tty_port_initialized(&info->port))
 		goto exit;
 
@@ -2412,9 +2352,6 @@ static void mgslpc_hangup(struct tty_struct *tty)
 		printk("%s(%d):mgslpc_hangup(%s)\n",
 			 __FILE__, __LINE__, info->device_name);
 
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_hangup"))
-		return;
-
 	mgslpc_flush_buffer(tty);
 	shutdown(info, tty);
 	tty_port_hangup(&info->port);
@@ -2468,8 +2405,10 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
 	info = mgslpc_device_list;
 	while(info && info->line != line)
 		info = info->next_device;
-	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_open"))
+	if (!info) {
+		pr_warn("%s: no device for line #%d.\n", __func__, line);
 		return -ENODEV;
+	}
 
 	port = &info->port;
 	tty->driver_data = info;
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 05/15] coda: remove CODA_MAGIC
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
                   ` (3 preceding siblings ...)
  2022-11-11  1:13 ` [PATCH v3 04/15] pcmcia: synclink_cs: remove dead paranoia_check, warn for missing line Ahelenia Ziemiańska
@ 2022-11-11  1:13 ` Ahelenia Ziemiańska
  2022-11-11  3:13   ` Jan Harkes
  2022-11-11  1:14 ` [PATCH v3 06/15] Documentation: remove PG_MAGIC (not a magic number) Ahelenia Ziemiańska
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:13 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Jan Harkes, coda, Greg Kroah-Hartman, Jiri Slaby, Jakub Kicinski,
	linux-doc, linux-kernel, linux-doc-tw-discuss, codalist

[-- Attachment #1: Type: text/plain, Size: 6332 bytes --]

We have largely moved away from this approach, and we have better
debugging tooling nowadays: kill it.

Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst                    | 1 -
 Documentation/translations/it_IT/process/magic-number.rst | 1 -
 Documentation/translations/zh_CN/process/magic-number.rst | 1 -
 Documentation/translations/zh_TW/process/magic-number.rst | 1 -
 fs/coda/cnode.c                                           | 2 +-
 fs/coda/coda_fs_i.h                                       | 2 --
 fs/coda/file.c                                            | 1 -
 7 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index 18f8b1e3a993..335169e43be1 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -74,7 +74,6 @@ FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
-CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index 827167b18f15..699b681088ac 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -80,7 +80,6 @@ FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
-CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 9553475e9867..d1ede86944f1 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -63,7 +63,6 @@ FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
-CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index 8a64f56ae267..1dd01f1e1c17 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -66,7 +66,6 @@ FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
-CODA_MAGIC            0xC0DAC0DA       coda_file_info           ``fs/coda/coda_fs_i.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c
index 62a3d2565c26..e217cca338bd 100644
--- a/fs/coda/cnode.c
+++ b/fs/coda/cnode.c
@@ -157,7 +157,7 @@ struct coda_file_info *coda_ftoc(struct file *file)
 {
 	struct coda_file_info *cfi = file->private_data;
 
-	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
+	BUG_ON(!cfi);
 
 	return cfi;
 
diff --git a/fs/coda/coda_fs_i.h b/fs/coda/coda_fs_i.h
index 1763ff95d865..9e4b54dbe7d7 100644
--- a/fs/coda/coda_fs_i.h
+++ b/fs/coda/coda_fs_i.h
@@ -35,9 +35,7 @@ struct coda_inode_info {
 /*
  * coda fs file private data
  */
-#define CODA_MAGIC 0xC0DAC0DA
 struct coda_file_info {
-	int		   cfi_magic;	  /* magic number */
 	struct file	  *cfi_container; /* container file for this cnode */
 	unsigned int	   cfi_mapcount;  /* nr of times this file is mapped */
 	bool		   cfi_access_intent; /* is access intent supported */
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 3f3c81e6b1ab..c23f846bf206 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -222,7 +222,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file)
 
 	host_file->f_flags |= coda_file->f_flags & (O_APPEND | O_SYNC);
 
-	cfi->cfi_magic = CODA_MAGIC;
 	cfi->cfi_mapcount = 0;
 	cfi->cfi_container = host_file;
 	/* assume access intents are supported unless we hear otherwise */
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 06/15] Documentation: remove PG_MAGIC (not a magic number)
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
                   ` (4 preceding siblings ...)
  2022-11-11  1:13 ` [PATCH v3 05/15] coda: remove CODA_MAGIC Ahelenia Ziemiańska
@ 2022-11-11  1:14 ` Ahelenia Ziemiańska
  2022-11-11  1:14 ` [PATCH v3 07/15] Documentation: remove NMI_MAGIC " Ahelenia Ziemiańska
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:14 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, Jiri Slaby, Jakub Kicinski, linux-doc,
	linux-kernel, linux-doc-tw-discuss

[-- Attachment #1: Type: text/plain, Size: 4349 bytes --]

It's part of the userspace I/O packet protocol.

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst                    | 1 -
 Documentation/translations/it_IT/process/magic-number.rst | 1 -
 Documentation/translations/zh_CN/process/magic-number.rst | 1 -
 Documentation/translations/zh_TW/process/magic-number.rst | 1 -
 4 files changed, 4 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index 335169e43be1..62a3a2113e7c 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -68,7 +68,6 @@ Changelog::
 ===================== ================ ======================== ==========================================
 Magic Name            Number           Structure                File
 ===================== ================ ======================== ==========================================
-PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/pg.h``
 APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index 699b681088ac..b20a54ee6fb2 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -74,7 +74,6 @@ Registro dei cambiamenti::
 ===================== ================ ======================== ==========================================
 Nome magico           Numero           Struttura                File
 ===================== ================ ======================== ==========================================
-PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/pg.h``
 APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index d1ede86944f1..e7781ab923f7 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -57,7 +57,6 @@ Linux 魔术数
 ===================== ================ ======================== ==========================================
 魔术数名              数字             结构                     文件
 ===================== ================ ======================== ==========================================
-PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/pg.h``
 APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index 1dd01f1e1c17..5cc0bfa97d9d 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -60,7 +60,6 @@ Linux 魔術數
 ===================== ================ ======================== ==========================================
 魔術數名              數字             結構                     文件
 ===================== ================ ======================== ==========================================
-PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/pg.h``
 APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 07/15] Documentation: remove NMI_MAGIC (not a magic number)
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
                   ` (5 preceding siblings ...)
  2022-11-11  1:14 ` [PATCH v3 06/15] Documentation: remove PG_MAGIC (not a magic number) Ahelenia Ziemiańska
@ 2022-11-11  1:14 ` Ahelenia Ziemiańska
  2022-11-11  1:14 ` [PATCH v3 08/15] MIPS: IP27: remove KV_MAGIC Ahelenia Ziemiańska
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:14 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, Jiri Slaby, Jakub Kicinski, linux-doc,
	linux-kernel, linux-doc-tw-discuss

[-- Attachment #1: Type: text/plain, Size: 4024 bytes --]

NMI_MAGIC is part of the firmware API

Link: https://lore.kernel.org/all/20221104145002.GA16099@alpha.franken.de/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst                    | 1 -
 Documentation/translations/it_IT/process/magic-number.rst | 1 -
 Documentation/translations/zh_CN/process/magic-number.rst | 1 -
 Documentation/translations/zh_TW/process/magic-number.rst | 1 -
 4 files changed, 4 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index 62a3a2113e7c..7dada7abc733 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -76,5 +76,4 @@ KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/incl
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
-NMI_MAGIC             0x48414d4d455201 nmi_s                    ``arch/mips/include/asm/sn/nmi.h``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index b20a54ee6fb2..f9634a04d349 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -82,5 +82,4 @@ KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/incl
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
-NMI_MAGIC             0x48414d4d455201 nmi_s                    ``arch/mips/include/asm/sn/nmi.h``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index e7781ab923f7..966b9e6b1a46 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -65,5 +65,4 @@ KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/incl
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
-NMI_MAGIC             0x48414d4d455201 nmi_s                    ``arch/mips/include/asm/sn/nmi.h``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index 5cc0bfa97d9d..f3e87a6b3a01 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -68,5 +68,4 @@ KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/incl
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
-NMI_MAGIC             0x48414d4d455201 nmi_s                    ``arch/mips/include/asm/sn/nmi.h``
 ===================== ================ ======================== ==========================================
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 08/15] MIPS: IP27: remove KV_MAGIC
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
                   ` (6 preceding siblings ...)
  2022-11-11  1:14 ` [PATCH v3 07/15] Documentation: remove NMI_MAGIC " Ahelenia Ziemiańska
@ 2022-11-11  1:14 ` Ahelenia Ziemiańska
  2022-11-11  5:40   ` Cye Borg
       [not found]   ` <CAD4NMuYU6+JYGwCwDqGW5bTN8Rgg4SwseH9JKzjPAzsujBuCEw@mail.gmail.com>
  2022-11-11  1:14 ` [PATCH v3 09/15] x86/APM: remove APM_BIOS_MAGIC Ahelenia Ziemiańska
                   ` (6 subsequent siblings)
  14 siblings, 2 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:14 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Thomas Bogendoerfer, Greg Kroah-Hartman, Jiri Slaby,
	Jakub Kicinski, Bagas Sanjaya, linux-doc, linux-kernel,
	linux-doc-tw-discuss, linux-mips

[-- Attachment #1: Type: text/plain, Size: 6114 bytes --]

It appeared in the original import of SGI code in 2.4.0-test3pre8 and
has never been used anywhere.

Reviewed-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst                    | 1 -
 Documentation/translations/it_IT/process/magic-number.rst | 1 -
 Documentation/translations/zh_CN/process/magic-number.rst | 1 -
 Documentation/translations/zh_TW/process/magic-number.rst | 1 -
 arch/mips/include/asm/sn/klkernvars.h                     | 8 ++------
 arch/mips/sgi-ip27/ip27-klnuma.c                          | 1 -
 6 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index 7dada7abc733..d8ffbc21872e 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -72,7 +72,6 @@ APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kerne
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
-KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index f9634a04d349..0e59704aa617 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -78,7 +78,6 @@ APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kerne
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
-KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 966b9e6b1a46..17a73661ef17 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -61,7 +61,6 @@ APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kerne
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
-KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index f3e87a6b3a01..9d44d49b93bf 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -64,7 +64,6 @@ APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kerne
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
-KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
 QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
diff --git a/arch/mips/include/asm/sn/klkernvars.h b/arch/mips/include/asm/sn/klkernvars.h
index ea6b21795163..93d5eb873255 100644
--- a/arch/mips/include/asm/sn/klkernvars.h
+++ b/arch/mips/include/asm/sn/klkernvars.h
@@ -6,18 +6,14 @@
 #ifndef __ASM_SN_KLKERNVARS_H
 #define __ASM_SN_KLKERNVARS_H
 
-#define KV_MAGIC_OFFSET		0x0
-#define KV_RO_NASID_OFFSET	0x4
-#define KV_RW_NASID_OFFSET	0x6
-
-#define KV_MAGIC		0x5f4b565f
+#define KV_RO_NASID_OFFSET	0x0
+#define KV_RW_NASID_OFFSET	0x2
 
 #ifndef __ASSEMBLY__
 
 #include <asm/sn/types.h>
 
 typedef struct kern_vars_s {
-	int		kv_magic;
 	nasid_t		kv_ro_nasid;
 	nasid_t		kv_rw_nasid;
 	unsigned long	kv_ro_baseaddr;
diff --git a/arch/mips/sgi-ip27/ip27-klnuma.c b/arch/mips/sgi-ip27/ip27-klnuma.c
index abd7a84df7dd..82bb7ac20ef8 100644
--- a/arch/mips/sgi-ip27/ip27-klnuma.c
+++ b/arch/mips/sgi-ip27/ip27-klnuma.c
@@ -61,7 +61,6 @@ static __init void set_ktext_source(nasid_t client_nasid, nasid_t server_nasid)
 
 	KERN_VARS_ADDR(client_nasid) = (unsigned long)kvp;
 
-	kvp->kv_magic = KV_MAGIC;
 	kvp->kv_ro_nasid = server_nasid;
 	kvp->kv_rw_nasid = master_nasid;
 	kvp->kv_ro_baseaddr = NODE_CAC_BASE(server_nasid);
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 09/15] x86/APM: remove APM_BIOS_MAGIC
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
                   ` (7 preceding siblings ...)
  2022-11-11  1:14 ` [PATCH v3 08/15] MIPS: IP27: remove KV_MAGIC Ahelenia Ziemiańska
@ 2022-11-11  1:14 ` Ahelenia Ziemiańska
  2022-11-11  1:14 ` [PATCH v3 10/15] scsi: acorn: remove QUEUE_MAGIC_{FREE,USED} Ahelenia Ziemiańska
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:14 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Jiri Kosina, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Greg Kroah-Hartman,
	Jakub Kicinski, Jiri Slaby, Kees Cook, Peter Zijlstra,
	Josh Poimboeuf, linux-doc, linux-kernel, linux-doc-tw-discuss

[-- Attachment #1: Type: text/plain, Size: 5758 bytes --]

We have largely moved away from this approach, and we have better
debugging instrumentation nowadays: kill it.

Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst                   | 1 -
 .../translations/it_IT/process/magic-number.rst          | 1 -
 .../translations/zh_CN/process/magic-number.rst          | 1 -
 .../translations/zh_TW/process/magic-number.rst          | 1 -
 arch/x86/kernel/apm_32.c                                 | 9 +--------
 5 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index d8ffbc21872e..77a96a79c7e8 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -68,7 +68,6 @@ Changelog::
 ===================== ================ ======================== ==========================================
 Magic Name            Number           Structure                File
 ===================== ================ ======================== ==========================================
-APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index 0e59704aa617..ef509265a3df 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -74,7 +74,6 @@ Registro dei cambiamenti::
 ===================== ================ ======================== ==========================================
 Nome magico           Numero           Struttura                File
 ===================== ================ ======================== ==========================================
-APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 17a73661ef17..6437c408dd67 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -57,7 +57,6 @@ Linux 魔术数
 ===================== ================ ======================== ==========================================
 魔术数名              数字             结构                     文件
 ===================== ================ ======================== ==========================================
-APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index 9d44d49b93bf..453cc205e6c3 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -60,7 +60,6 @@ Linux 魔術數
 ===================== ================ ======================== ==========================================
 魔術數名              數字             結構                     文件
 ===================== ================ ======================== ==========================================
-APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 60e330cdbd17..f3dd21dc56b7 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -330,7 +330,6 @@ extern int (*console_blank_hook)(int);
  * The per-file APM data
  */
 struct apm_user {
-	int		magic;
 	struct apm_user *next;
 	unsigned int	suser: 1;
 	unsigned int	writer: 1;
@@ -346,11 +345,6 @@ struct apm_user {
 	apm_event_t	events[APM_MAX_EVENTS];
 };
 
-/*
- * The magic number in apm_user
- */
-#define APM_BIOS_MAGIC		0x4101
-
 /*
  * idle percentage above which bios idle calls are done
  */
@@ -1459,7 +1453,7 @@ static void apm_mainloop(void)
 
 static int check_apm_user(struct apm_user *as, const char *func)
 {
-	if (as == NULL || as->magic != APM_BIOS_MAGIC) {
+	if (as == NULL) {
 		pr_err("%s passed bad filp\n", func);
 		return 1;
 	}
@@ -1616,7 +1610,6 @@ static int do_open(struct inode *inode, struct file *filp)
 	if (as == NULL)
 		return -ENOMEM;
 
-	as->magic = APM_BIOS_MAGIC;
 	as->event_tail = as->event_head = 0;
 	as->suspends_pending = as->standbys_pending = 0;
 	as->suspends_read = as->standbys_read = 0;
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 10/15] scsi: acorn: remove QUEUE_MAGIC_{FREE,USED}
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
                   ` (8 preceding siblings ...)
  2022-11-11  1:14 ` [PATCH v3 09/15] x86/APM: remove APM_BIOS_MAGIC Ahelenia Ziemiańska
@ 2022-11-11  1:14 ` Ahelenia Ziemiańska
  2022-11-11  1:14 ` [PATCH v3 11/15] hdlcdrv: remove HDLCDRV_MAGIC Ahelenia Ziemiańska
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:14 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Russell King, James E.J. Bottomley, Martin K. Petersen,
	Greg Kroah-Hartman, Jiri Slaby, Jakub Kicinski, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-scsi

[-- Attachment #1: Type: text/plain, Size: 6033 bytes --]

We have largely moved away from this approach, and we have better
debugging instrumentation nowadays: kill it.

Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst        |  2 --
 .../it_IT/process/magic-number.rst            |  2 --
 .../zh_CN/process/magic-number.rst            |  2 --
 .../zh_TW/process/magic-number.rst            |  2 --
 drivers/scsi/arm/queue.c                      | 21 -------------------
 5 files changed, 29 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index 77a96a79c7e8..c1c68c713cbc 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -72,6 +72,4 @@ FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
-QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
-QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index ef509265a3df..5b609ca78a14 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -78,6 +78,4 @@ FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
-QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
-QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 6437c408dd67..ab4d4e32b61f 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -61,6 +61,4 @@ FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
-QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
-QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index 453cc205e6c3..a6131d978189 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -64,6 +64,4 @@ FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
-QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
-QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
 ===================== ================ ======================== ==========================================
diff --git a/drivers/scsi/arm/queue.c b/drivers/scsi/arm/queue.c
index 978df23ce188..fe7d814a73a9 100644
--- a/drivers/scsi/arm/queue.c
+++ b/drivers/scsi/arm/queue.c
@@ -26,27 +26,11 @@
 #include <scsi/scsi_eh.h>
 #include <scsi/scsi_tcq.h>
 
-#define DEBUG
-
 typedef struct queue_entry {
 	struct list_head   list;
 	struct scsi_cmnd   *SCpnt;
-#ifdef DEBUG
-	unsigned long	   magic;
-#endif
 } QE_t;
 
-#ifdef DEBUG
-#define QUEUE_MAGIC_FREE	0xf7e1c9a3
-#define QUEUE_MAGIC_USED	0xf7e1cc33
-
-#define SET_MAGIC(q,m)	((q)->magic = (m))
-#define BAD_MAGIC(q,m)	((q)->magic != (m))
-#else
-#define SET_MAGIC(q,m)	do { } while (0)
-#define BAD_MAGIC(q,m)	(0)
-#endif
-
 #include "queue.h"
 
 #define NR_QE	32
@@ -74,7 +58,6 @@ int queue_initialise (Queue_t *queue)
 	queue->alloc = q = kmalloc_array(nqueues, sizeof(QE_t), GFP_KERNEL);
 	if (q) {
 		for (; nqueues; q++, nqueues--) {
-			SET_MAGIC(q, QUEUE_MAGIC_FREE);
 			q->SCpnt = NULL;
 			list_add(&q->list, &queue->free);
 		}
@@ -119,9 +102,7 @@ int __queue_add(Queue_t *queue, struct scsi_cmnd *SCpnt, int head)
 	list_del(l);
 
 	q = list_entry(l, QE_t, list);
-	BUG_ON(BAD_MAGIC(q, QUEUE_MAGIC_FREE));
 
-	SET_MAGIC(q, QUEUE_MAGIC_USED);
 	q->SCpnt = SCpnt;
 
 	if (head)
@@ -144,9 +125,7 @@ static struct scsi_cmnd *__queue_remove(Queue_t *queue, struct list_head *ent)
 	 */
 	list_del(ent);
 	q = list_entry(ent, QE_t, list);
-	BUG_ON(BAD_MAGIC(q, QUEUE_MAGIC_USED));
 
-	SET_MAGIC(q, QUEUE_MAGIC_FREE);
 	list_add(ent, &queue->free);
 
 	return q->SCpnt;
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 11/15] hdlcdrv: remove HDLCDRV_MAGIC
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
                   ` (9 preceding siblings ...)
  2022-11-11  1:14 ` [PATCH v3 10/15] scsi: acorn: remove QUEUE_MAGIC_{FREE,USED} Ahelenia Ziemiańska
@ 2022-11-11  1:14 ` Ahelenia Ziemiańska
  2022-11-11  1:14 ` [PATCH v3 12/15] drivers: net: slip: remove SLIP_MAGIC Ahelenia Ziemiańska
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:14 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Thomas Sailer, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Greg Kroah-Hartman, Jiri Slaby, Marc Kleine-Budde,
	Jason A. Donenfeld, Kees Cook, Wolfram Sang, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-hams, netdev

[-- Attachment #1: Type: text/plain, Size: 9081 bytes --]

We have largely moved away from this approach, and we have better
debugging instrumentation nowadays: kill it.

Additionally, ~half HDLCDRV_MAGIC checks just early-exit instead of
noting the bug, so they're detrimental, if anything.

Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst                   | 1 -
 .../translations/it_IT/process/magic-number.rst          | 1 -
 .../translations/zh_CN/process/magic-number.rst          | 1 -
 .../translations/zh_TW/process/magic-number.rst          | 1 -
 drivers/net/hamradio/baycom_par.c                        | 1 -
 drivers/net/hamradio/baycom_ser_fdx.c                    | 3 +--
 drivers/net/hamradio/baycom_ser_hdx.c                    | 3 +--
 drivers/net/hamradio/hdlcdrv.c                           | 9 +++------
 include/linux/hdlcdrv.h                                  | 2 --
 9 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index c1c68c713cbc..3b3e607e1cbc 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -70,6 +70,5 @@ Magic Name            Number           Structure                File
 ===================== ================ ======================== ==========================================
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
-HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index 5b609ca78a14..e8c659b6a743 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -76,6 +76,5 @@ Nome magico           Numero           Struttura                File
 ===================== ================ ======================== ==========================================
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
-HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index ab4d4e32b61f..2105af32187c 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -59,6 +59,5 @@ Linux 魔术数
 ===================== ================ ======================== ==========================================
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
-HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index a6131d978189..793a0ae9fb7c 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -62,6 +62,5 @@ Linux 魔術數
 ===================== ================ ======================== ==========================================
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
-HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/drivers/net/hamradio/baycom_par.c b/drivers/net/hamradio/baycom_par.c
index fd7da5bb1fa5..e1cf3ed42df6 100644
--- a/drivers/net/hamradio/baycom_par.c
+++ b/drivers/net/hamradio/baycom_par.c
@@ -418,7 +418,6 @@ static int baycom_ioctl(struct net_device *dev, void __user *data,
 		return -EINVAL;
 
 	bc = netdev_priv(dev);
-	BUG_ON(bc->hdrv.magic != HDLCDRV_MAGIC);
 
 	if (cmd != SIOCDEVPRIVATE)
 		return -ENOIOCTLCMD;
diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c
index 646f605e358f..65113cb6de8d 100644
--- a/drivers/net/hamradio/baycom_ser_fdx.c
+++ b/drivers/net/hamradio/baycom_ser_fdx.c
@@ -252,7 +252,7 @@ static irqreturn_t ser12_interrupt(int irq, void *dev_id)
 	unsigned char iir, msr;
 	unsigned int txcount = 0;
 
-	if (!bc || bc->hdrv.magic != HDLCDRV_MAGIC)
+	if (!bc)
 		return IRQ_NONE;
 	/* fast way out for shared irq */
 	if ((iir = inb(IIR(dev->base_addr))) & 1) 	
@@ -507,7 +507,6 @@ static int baycom_ioctl(struct net_device *dev, void __user *data,
 		return -EINVAL;
 
 	bc = netdev_priv(dev);
-	BUG_ON(bc->hdrv.magic != HDLCDRV_MAGIC);
 
 	if (cmd != SIOCDEVPRIVATE)
 		return -ENOIOCTLCMD;
diff --git a/drivers/net/hamradio/baycom_ser_hdx.c b/drivers/net/hamradio/baycom_ser_hdx.c
index 5d1ab4840753..df33e5cdb5c2 100644
--- a/drivers/net/hamradio/baycom_ser_hdx.c
+++ b/drivers/net/hamradio/baycom_ser_hdx.c
@@ -365,7 +365,7 @@ static irqreturn_t ser12_interrupt(int irq, void *dev_id)
 	struct baycom_state *bc = netdev_priv(dev);
 	unsigned char iir;
 
-	if (!dev || !bc || bc->hdrv.magic != HDLCDRV_MAGIC)
+	if (!dev || !bc)
 		return IRQ_NONE;
 	/* fast way out */
 	if ((iir = inb(IIR(dev->base_addr))) & 1)
@@ -561,7 +561,6 @@ static int baycom_ioctl(struct net_device *dev, void __user *data,
 		return -EINVAL;
 
 	bc = netdev_priv(dev);
-	BUG_ON(bc->hdrv.magic != HDLCDRV_MAGIC);
 
 	if (cmd != SIOCDEVPRIVATE)
 		return -ENOIOCTLCMD;
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 2263029d1a20..60abd6008cc7 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -158,7 +158,7 @@ void hdlcdrv_receiver(struct net_device *dev, struct hdlcdrv_state *s)
 	int i;
 	unsigned int mask1, mask2, mask3, mask4, mask5, mask6, word;
 	
-	if (!s || s->magic != HDLCDRV_MAGIC) 
+	if (!s)
 		return;
 	if (test_and_set_bit(0, &s->hdlcrx.in_hdlc_rx))
 		return;
@@ -257,7 +257,7 @@ void hdlcdrv_transmitter(struct net_device *dev, struct hdlcdrv_state *s)
 	struct sk_buff *skb;
 	int pkt_len;
 
-	if (!s || s->magic != HDLCDRV_MAGIC) 
+	if (!s)
 		return;
 	if (test_and_set_bit(0, &s->hdlctx.in_hdlc_tx))
 		return;
@@ -364,7 +364,7 @@ static void start_tx(struct net_device *dev, struct hdlcdrv_state *s)
 
 void hdlcdrv_arbitrate(struct net_device *dev, struct hdlcdrv_state *s)
 {
-	if (!s || s->magic != HDLCDRV_MAGIC || s->hdlctx.ptt || !s->skb) 
+	if (!s || s->hdlctx.ptt || !s->skb)
 		return;
 	if (s->ch_params.fulldup) {
 		start_tx(dev, s);
@@ -701,7 +701,6 @@ struct net_device *hdlcdrv_register(const struct hdlcdrv_ops *ops,
 	 * initialize part of the hdlcdrv_state struct
 	 */
 	s = netdev_priv(dev);
-	s->magic = HDLCDRV_MAGIC;
 	s->ops = ops;
 	dev->base_addr = baseaddr;
 	dev->irq = irq;
@@ -723,8 +722,6 @@ void hdlcdrv_unregister(struct net_device *dev)
 {
 	struct hdlcdrv_state *s = netdev_priv(dev);
 
-	BUG_ON(s->magic != HDLCDRV_MAGIC);
-
 	if (s->opened && s->ops->close)
 		s->ops->close(dev);
 	unregister_netdev(dev);
diff --git a/include/linux/hdlcdrv.h b/include/linux/hdlcdrv.h
index 5d70c3f98f5b..809ad0f5c99c 100644
--- a/include/linux/hdlcdrv.h
+++ b/include/linux/hdlcdrv.h
@@ -13,7 +13,6 @@
 #include <linux/spinlock.h>
 #include <uapi/linux/hdlcdrv.h>
 
-#define HDLCDRV_MAGIC      0x5ac6e778
 #define HDLCDRV_HDLCBUFFER  32 /* should be a power of 2 for speed reasons */
 #define HDLCDRV_BITBUFFER  256 /* should be a power of 2 for speed reasons */
 #undef HDLCDRV_LOOPBACK  /* define for HDLC debugging purposes */
@@ -84,7 +83,6 @@ struct hdlcdrv_ops {
 };
 
 struct hdlcdrv_state {
-	int magic;
 	int opened;
 
 	const struct hdlcdrv_ops *ops;
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 12/15] drivers: net: slip: remove SLIP_MAGIC
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
                   ` (10 preceding siblings ...)
  2022-11-11  1:14 ` [PATCH v3 11/15] hdlcdrv: remove HDLCDRV_MAGIC Ahelenia Ziemiańska
@ 2022-11-11  1:14 ` Ahelenia Ziemiańska
  2022-11-11  1:14 ` [PATCH v3 13/15] fcntl: remove FASYNC_MAGIC Ahelenia Ziemiańska
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:14 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Greg Kroah-Hartman, Jiri Slaby, Oliver Hartkopp,
	Sebastian Andrzej Siewior, Marc Kleine-Budde, Duoming Zhou,
	Huang Pei, linux-doc, linux-kernel, linux-doc-tw-discuss, netdev

[-- Attachment #1: Type: text/plain, Size: 6973 bytes --]

According to Greg, in the context of magic numbers as defined in
magic-number.rst, "the tty layer should not need this and I'll gladly
take patches".

We have largely moved away from this approach, and we have better
debugging instrumentation nowadays: kill it.

Additionally, all SLIP_MAGIC checks just early-exit instead of noting
the bug, so they're detrimental, if anything.

Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Reviewed-by: Oliver Hartkopp <socketcan@hartkopp.net>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst                |  1 -
 .../translations/it_IT/process/magic-number.rst       |  1 -
 .../translations/zh_CN/process/magic-number.rst       |  1 -
 .../translations/zh_TW/process/magic-number.rst       |  1 -
 drivers/net/slip/slip.c                               | 11 +++++------
 drivers/net/slip/slip.h                               |  4 ----
 6 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index 3b3e607e1cbc..e59c707ec785 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -69,6 +69,5 @@ Changelog::
 Magic Name            Number           Structure                File
 ===================== ================ ======================== ==========================================
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
-SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index e8c659b6a743..37a539867b6f 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -75,6 +75,5 @@ Registro dei cambiamenti::
 Nome magico           Numero           Struttura                File
 ===================== ================ ======================== ==========================================
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
-SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 2105af32187c..8a3a3e872c52 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -58,6 +58,5 @@ Linux 魔术数
 魔术数名              数字             结构                     文件
 ===================== ================ ======================== ==========================================
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
-SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index 793a0ae9fb7c..7ace7834f7f9 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -61,6 +61,5 @@ Linux 魔術數
 魔術數名              數字             結構                     文件
 ===================== ================ ======================== ==========================================
 FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
-SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index 6865d32270e5..95f5c79772e7 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -426,7 +426,7 @@ static void slip_transmit(struct work_struct *work)
 
 	spin_lock_bh(&sl->lock);
 	/* First make sure we're connected. */
-	if (!sl->tty || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) {
+	if (!sl->tty || !netif_running(sl->dev)) {
 		spin_unlock_bh(&sl->lock);
 		return;
 	}
@@ -690,7 +690,7 @@ static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 {
 	struct slip *sl = tty->disc_data;
 
-	if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev))
+	if (!sl || !netif_running(sl->dev))
 		return;
 
 	/* Read the characters out of the buffer */
@@ -761,7 +761,6 @@ static struct slip *sl_alloc(void)
 	sl = netdev_priv(dev);
 
 	/* Initialize channel control data */
-	sl->magic       = SLIP_MAGIC;
 	sl->dev	      	= dev;
 	spin_lock_init(&sl->lock);
 	INIT_WORK(&sl->tx_work, slip_transmit);
@@ -809,7 +808,7 @@ static int slip_open(struct tty_struct *tty)
 
 	err = -EEXIST;
 	/* First make sure we're not already connected. */
-	if (sl && sl->magic == SLIP_MAGIC)
+	if (sl)
 		goto err_exit;
 
 	/* OK.  Find a free SLIP channel to use. */
@@ -886,7 +885,7 @@ static void slip_close(struct tty_struct *tty)
 	struct slip *sl = tty->disc_data;
 
 	/* First make sure we're connected. */
-	if (!sl || sl->magic != SLIP_MAGIC || sl->tty != tty)
+	if (!sl || sl->tty != tty)
 		return;
 
 	spin_lock_bh(&sl->lock);
@@ -1080,7 +1079,7 @@ static int slip_ioctl(struct tty_struct *tty, unsigned int cmd,
 	int __user *p = (int __user *)arg;
 
 	/* First make sure we're connected. */
-	if (!sl || sl->magic != SLIP_MAGIC)
+	if (!sl)
 		return -EINVAL;
 
 	switch (cmd) {
diff --git a/drivers/net/slip/slip.h b/drivers/net/slip/slip.h
index 3d7f88b330c1..d7dbedd27669 100644
--- a/drivers/net/slip/slip.h
+++ b/drivers/net/slip/slip.h
@@ -50,8 +50,6 @@
 
 
 struct slip {
-  int			magic;
-
   /* Various fields. */
   struct tty_struct	*tty;		/* ptr to TTY structure		*/
   struct net_device	*dev;		/* easy for intr handling	*/
@@ -100,6 +98,4 @@ struct slip {
 #endif
 };
 
-#define SLIP_MAGIC 0x5302
-
 #endif	/* _LINUX_SLIP.H */
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 13/15] fcntl: remove FASYNC_MAGIC
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
                   ` (11 preceding siblings ...)
  2022-11-11  1:14 ` [PATCH v3 12/15] drivers: net: slip: remove SLIP_MAGIC Ahelenia Ziemiańska
@ 2022-11-11  1:14 ` Ahelenia Ziemiańska
  2022-11-11 10:00   ` Jeff Layton
  2022-11-11  1:14 ` [PATCH v3 14/15] scsi: ncr53c8xx: replace CCB_MAGIC with bool busy Ahelenia Ziemiańska
  2022-11-11  1:14 ` [PATCH v3 15/15] Documentation: remove magic-number.rst Ahelenia Ziemiańska
  14 siblings, 1 reply; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:14 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Jeff Layton, Chuck Lever, Alexander Viro, Greg Kroah-Hartman,
	Jakub Kicinski, Jiri Slaby, linux-doc, linux-kernel,
	linux-doc-tw-discuss, linux-fsdevel

[-- Attachment #1: Type: text/plain, Size: 5822 bytes --]

We have largely moved away from this approach, and we have better
debugging instrumentation nowadays: kill it.

Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst                    | 1 -
 Documentation/translations/it_IT/process/magic-number.rst | 1 -
 Documentation/translations/zh_CN/process/magic-number.rst | 1 -
 Documentation/translations/zh_TW/process/magic-number.rst | 1 -
 fs/fcntl.c                                                | 6 ------
 include/linux/fs.h                                        | 3 ---
 6 files changed, 13 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index e59c707ec785..6e432917a5a8 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -68,6 +68,5 @@ Changelog::
 ===================== ================ ======================== ==========================================
 Magic Name            Number           Structure                File
 ===================== ================ ======================== ==========================================
-FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index 37a539867b6f..7d4c117ac626 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -74,6 +74,5 @@ Registro dei cambiamenti::
 ===================== ================ ======================== ==========================================
 Nome magico           Numero           Struttura                File
 ===================== ================ ======================== ==========================================
-FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 8a3a3e872c52..c17e3f20440a 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -57,6 +57,5 @@ Linux 魔术数
 ===================== ================ ======================== ==========================================
 魔术数名              数字             结构                     文件
 ===================== ================ ======================== ==========================================
-FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index 7ace7834f7f9..e2eeb74e7192 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -60,6 +60,5 @@ Linux 魔術數
 ===================== ================ ======================== ==========================================
 魔術數名              數字             結構                     文件
 ===================== ================ ======================== ==========================================
-FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
 CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 146c9ab0cd4b..e366a3804108 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -924,7 +924,6 @@ struct fasync_struct *fasync_insert_entry(int fd, struct file *filp, struct fasy
 	}
 
 	rwlock_init(&new->fa_lock);
-	new->magic = FASYNC_MAGIC;
 	new->fa_file = filp;
 	new->fa_fd = fd;
 	new->fa_next = *fapp;
@@ -988,11 +987,6 @@ static void kill_fasync_rcu(struct fasync_struct *fa, int sig, int band)
 		struct fown_struct *fown;
 		unsigned long flags;
 
-		if (fa->magic != FASYNC_MAGIC) {
-			printk(KERN_ERR "kill_fasync: bad magic number in "
-			       "fasync_struct!\n");
-			return;
-		}
 		read_lock_irqsave(&fa->fa_lock, flags);
 		if (fa->fa_file) {
 			fown = &fa->fa_file->f_owner;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e654435f1651..acfd5db5341a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1345,15 +1345,12 @@ static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)
 
 struct fasync_struct {
 	rwlock_t		fa_lock;
-	int			magic;
 	int			fa_fd;
 	struct fasync_struct	*fa_next; /* singly linked list */
 	struct file		*fa_file;
 	struct rcu_head		fa_rcu;
 };
 
-#define FASYNC_MAGIC 0x4601
-
 /* SMP safe fasync helpers: */
 extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
 extern struct fasync_struct *fasync_insert_entry(int, struct file *, struct fasync_struct **, struct fasync_struct *);
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 14/15] scsi: ncr53c8xx: replace CCB_MAGIC with bool busy
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
                   ` (12 preceding siblings ...)
  2022-11-11  1:14 ` [PATCH v3 13/15] fcntl: remove FASYNC_MAGIC Ahelenia Ziemiańska
@ 2022-11-11  1:14 ` Ahelenia Ziemiańska
  2022-11-11  1:14 ` [PATCH v3 15/15] Documentation: remove magic-number.rst Ahelenia Ziemiańska
  14 siblings, 0 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:14 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	James E.J. Bottomley, Martin K. Petersen, Greg Kroah-Hartman,
	Jiri Slaby, Jakub Kicinski, linux-doc, linux-kernel,
	linux-doc-tw-discuss, linux-scsi

[-- Attachment #1: Type: text/plain, Size: 6405 bytes --]

The only non-boolean check might as well be, since it just early-exits
instead of noting the bug: lower it to a boolean and make it less
confusing.

As for magic numbers, we have largely moved away from this approach,
and we have better debugging instrumentation nowadays: kill it.

Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst        |  1 -
 .../it_IT/process/magic-number.rst            |  1 -
 .../zh_CN/process/magic-number.rst            |  1 -
 .../zh_TW/process/magic-number.rst            |  1 -
 drivers/scsi/ncr53c8xx.c                      | 25 ++++++-------------
 5 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index 6e432917a5a8..5a8c2755ac9c 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -68,5 +68,4 @@ Changelog::
 ===================== ================ ======================== ==========================================
 Magic Name            Number           Structure                File
 ===================== ================ ======================== ==========================================
-CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index 7d4c117ac626..2fbc1876534a 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -74,5 +74,4 @@ Registro dei cambiamenti::
 ===================== ================ ======================== ==========================================
 Nome magico           Numero           Struttura                File
 ===================== ================ ======================== ==========================================
-CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index c17e3f20440a..f8ec4767bc4e 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -57,5 +57,4 @@ Linux 魔术数
 ===================== ================ ======================== ==========================================
 魔术数名              数字             结构                     文件
 ===================== ================ ======================== ==========================================
-CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index e2eeb74e7192..0ccc60bee3d6 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -60,5 +60,4 @@ Linux 魔術數
 ===================== ================ ======================== ==========================================
 魔術數名              數字             結構                     文件
 ===================== ================ ======================== ==========================================
-CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
 ===================== ================ ======================== ==========================================
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index 4458449c960b..928417fca495 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -1095,15 +1095,6 @@ typedef u32 tagmap_t;
 #define NS_WIDE		(2)
 #define NS_PPR		(4)
 
-/*==========================================================
-**
-**	Misc.
-**
-**==========================================================
-*/
-
-#define CCB_MAGIC	(0xf2691ad2)
-
 /*==========================================================
 **
 **	Declaration of structs.
@@ -1567,7 +1558,7 @@ struct ccb {
 	struct ccb *	link_ccb;	/* Host adapter CCB chain	*/
 	struct list_head link_ccbq;	/* Link to unit CCB queue	*/
 	u32		startp;		/* Initial data pointer		*/
-	u_long		magic;		/* Free / busy  CCB flag	*/
+	bool		busy;
 };
 
 #define CCB_PHYS(cp,lbl)	(cp->p_ccb + offsetof(struct ccb, lbl))
@@ -4356,7 +4347,7 @@ static int ncr_queue_command (struct ncb *np, struct scsi_cmnd *cmd)
 	*/
 
 	/* activate this job.  */
-	cp->magic		= CCB_MAGIC;
+	cp->busy		= true;
 
 	/*
 	**	insert next CCBs into start queue.
@@ -4667,7 +4658,7 @@ void ncr_complete (struct ncb *np, struct ccb *cp)
 	**	Sanity check
 	*/
 
-	if (!cp || cp->magic != CCB_MAGIC || !cp->cmd)
+	if (!cp || !cp->busy || !cp->cmd)
 		return;
 
 	/*
@@ -6998,7 +6989,7 @@ static struct ccb *ncr_get_ccb(struct ncb *np, struct scsi_cmnd *cmd)
 		qp = ncr_list_pop(&lp->free_ccbq);
 		if (qp) {
 			cp = list_entry(qp, struct ccb, link_ccbq);
-			if (cp->magic) {
+			if (cp->busy) {
 				PRINT_ADDR(cmd, "ccb free list corrupted "
 						"(@%p)\n", cp);
 				cp = NULL;
@@ -7030,17 +7021,17 @@ static struct ccb *ncr_get_ccb(struct ncb *np, struct scsi_cmnd *cmd)
 	**	Wait until available.
 	*/
 #if 0
-	while (cp->magic) {
+	while (cp->busy) {
 		if (flags & SCSI_NOSLEEP) break;
 		if (tsleep ((caddr_t)cp, PRIBIO|PCATCH, "ncr", 0))
 			break;
 	}
 #endif
 
-	if (cp->magic)
+	if (cp->busy)
 		return NULL;
 
-	cp->magic = 1;
+	cp->busy = true;
 
 	/*
 	**	Move to next available tag if tag used.
@@ -7119,7 +7110,7 @@ static void ncr_free_ccb (struct ncb *np, struct ccb *cp)
 		}
 	}
 	cp -> host_status = HS_IDLE;
-	cp -> magic = 0;
+	cp -> busy = false;
 	if (cp->queued) {
 		--np->queuedccbs;
 		cp->queued = 0;
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 15/15] Documentation: remove magic-number.rst
  2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
                   ` (13 preceding siblings ...)
  2022-11-11  1:14 ` [PATCH v3 14/15] scsi: ncr53c8xx: replace CCB_MAGIC with bool busy Ahelenia Ziemiańska
@ 2022-11-11  1:14 ` Ahelenia Ziemiańska
  14 siblings, 0 replies; 20+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-11  1:14 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Steven Rostedt, Jani Nikula, Laura Abbott, Wenwen Wang,
	Thorsten Leemhuis, Kees Cook, Lukas Bulwahn, Greg Kroah-Hartman,
	Jiri Slaby, Jakub Kicinski, Wu XiangCheng, linux-doc,
	linux-kernel, linux-doc-tw-discuss

[-- Attachment #1: Type: text/plain, Size: 15198 bytes --]

All noted magic numbers have been removed, and we don't want to encourage
magicking up kernel structs going forward.

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/index.rst               |  1 -
 Documentation/process/magic-number.rst        | 71 -----------------
 .../translations/it_IT/process/index.rst      |  1 -
 .../it_IT/process/magic-number.rst            | 77 -------------------
 .../translations/zh_CN/process/index.rst      |  1 -
 .../zh_CN/process/magic-number.rst            | 60 ---------------
 .../translations/zh_TW/process/index.rst      |  1 -
 .../zh_TW/process/magic-number.rst            | 63 ---------------
 8 files changed, 275 deletions(-)
 delete mode 100644 Documentation/process/magic-number.rst
 delete mode 100644 Documentation/translations/it_IT/process/magic-number.rst
 delete mode 100644 Documentation/translations/zh_CN/process/magic-number.rst
 delete mode 100644 Documentation/translations/zh_TW/process/magic-number.rst

diff --git a/Documentation/process/index.rst b/Documentation/process/index.rst
index d4b6217472b0..a8c0c4bffa47 100644
--- a/Documentation/process/index.rst
+++ b/Documentation/process/index.rst
@@ -59,7 +59,6 @@ lack of a better place.
 
    applying-patches
    adding-syscalls
-   magic-number
    volatile-considered-harmful
    botching-up-ioctls
    clang-format
diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
deleted file mode 100644
index 5a8c2755ac9c..000000000000
--- a/Documentation/process/magic-number.rst
+++ /dev/null
@@ -1,71 +0,0 @@
-.. _magicnumbers:
-
-Linux magic numbers
-===================
-
-This file is a registry of magic numbers which are in use.  When you
-add a magic number to a structure, you should also add it to this
-file, since it is best if the magic numbers used by various structures
-are unique.
-
-It is a **very** good idea to protect kernel data structures with magic
-numbers.  This allows you to check at run time whether (a) a structure
-has been clobbered, or (b) you've passed the wrong structure to a
-routine.  This last is especially useful --- particularly when you are
-passing pointers to structures via a void * pointer.  The tty code,
-for example, does this frequently to pass driver-specific and line
-discipline-specific structures back and forth.
-
-The way to use magic numbers is to declare them at the beginning of
-the structure, like so::
-
-	struct tty_ldisc {
-		int	magic;
-		...
-	};
-
-Please follow this discipline when you are adding future enhancements
-to the kernel!  It has saved me countless hours of debugging,
-especially in the screwy cases where an array has been overrun and
-structures following the array have been overwritten.  Using this
-discipline, these cases get detected quickly and safely.
-
-Changelog::
-
-					Theodore Ts'o
-					31 Mar 94
-
-  The magic table is current to Linux 2.1.55.
-
-					Michael Chastain
-					<mailto:mec@shout.net>
-					22 Sep 1997
-
-  Now it should be up to date with Linux 2.1.112. Because
-  we are in feature freeze time it is very unlikely that
-  something will change before 2.2.x. The entries are
-  sorted by number field.
-
-					Krzysztof G. Baranowski
-					<mailto: kgb@knm.org.pl>
-					29 Jul 1998
-
-  Updated the magic table to Linux 2.5.45. Right over the feature freeze,
-  but it is possible that some new magic numbers will sneak into the
-  kernel before 2.6.x yet.
-
-					Petr Baudis
-					<pasky@ucw.cz>
-					03 Nov 2002
-
-  Updated the magic table to Linux 2.5.74.
-
-					Fabian Frederick
-					<ffrederick@users.sourceforge.net>
-					09 Jul 2003
-
-
-===================== ================ ======================== ==========================================
-Magic Name            Number           Structure                File
-===================== ================ ======================== ==========================================
-===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/it_IT/process/index.rst b/Documentation/translations/it_IT/process/index.rst
index 8d4e36a07ff4..71adf53bc297 100644
--- a/Documentation/translations/it_IT/process/index.rst
+++ b/Documentation/translations/it_IT/process/index.rst
@@ -56,7 +56,6 @@ perché non si è trovato un posto migliore.
 
    applying-patches
    adding-syscalls
-   magic-number
    volatile-considered-harmful
    clang-format
    ../riscv/patch-acceptance
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
deleted file mode 100644
index 2fbc1876534a..000000000000
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ /dev/null
@@ -1,77 +0,0 @@
-.. include:: ../disclaimer-ita.rst
-
-:Original: :ref:`Documentation/process/magic-number.rst <magicnumbers>`
-:Translator: Federico Vaga <federico.vaga@vaga.pv.it>
-
-.. _it_magicnumbers:
-
-I numeri magici di Linux
-========================
-
-Questo documento è un registro dei numeri magici in uso.  Quando
-aggiungete un numero magico ad una struttura, dovreste aggiungerlo anche
-a questo documento; la cosa migliore è che tutti i numeri magici usati
-dalle varie strutture siano unici.
-
-È **davvero** un'ottima idea proteggere le strutture dati del kernel con
-dei numeri magici.  Questo vi permette in fase d'esecuzione di (a) verificare
-se una struttura è stata malmenata, o (b) avete passato a una procedura la
-struttura errata.  Quest'ultimo è molto utile - particolarmente quando si passa
-una struttura dati tramite un puntatore void \*.  Il codice tty, per esempio,
-effettua questa operazione con regolarità passando avanti e indietro le
-strutture specifiche per driver e discipline.
-
-Per utilizzare un numero magico, dovete dichiararlo all'inizio della struttura
-dati, come di seguito::
-
-	struct tty_ldisc {
-		int	magic;
-		...
-	};
-
-Per favore, seguite questa direttiva quando aggiungerete migliorie al kernel!
-Mi ha risparmiato un numero illimitato di ore di debug, specialmente nei casi
-più ostici dove si è andati oltre la dimensione di un vettore e la struttura
-dati che lo seguiva in memoria è stata sovrascritta.  Seguendo questa
-direttiva, questi casi vengono identificati velocemente e in sicurezza.
-
-Registro dei cambiamenti::
-
-					Theodore Ts'o
-					31 Mar 94
-
-  La tabella magica è aggiornata a Linux 2.1.55.
-
-					Michael Chastain
-					<mailto:mec@shout.net>
-					22 Sep 1997
-
-  Ora dovrebbe essere aggiornata a Linux 2.1.112. Dato che
-  siamo in un momento di congelamento delle funzionalità
-  (*feature freeze*) è improbabile che qualcosa cambi prima
-  della versione 2.2.x.  Le righe sono ordinate secondo il
-  campo numero.
-
-					Krzysztof G. Baranowski
-					<mailto: kgb@knm.org.pl>
-					29 Jul 1998
-
-  Aggiornamento della tabella a Linux 2.5.45. Giusti nel congelamento
-  delle funzionalità ma è comunque possibile che qualche nuovo
-  numero magico s'intrufoli prima del kernel 2.6.x.
-
-					Petr Baudis
-					<pasky@ucw.cz>
-					03 Nov 2002
-
-  Aggiornamento della tabella magica a Linux 2.5.74.
-
-					Fabian Frederick
-					<ffrederick@users.sourceforge.net>
-					09 Jul 2003
-
-
-===================== ================ ======================== ==========================================
-Nome magico           Numero           Struttura                File
-===================== ================ ======================== ==========================================
-===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_CN/process/index.rst b/Documentation/translations/zh_CN/process/index.rst
index a1a35f88f4ae..300d579b3ad0 100644
--- a/Documentation/translations/zh_CN/process/index.rst
+++ b/Documentation/translations/zh_CN/process/index.rst
@@ -52,7 +52,6 @@
 .. toctree::
    :maxdepth: 1
 
-   magic-number
    volatile-considered-harmful
 
 .. only::  subproject and html
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
deleted file mode 100644
index f8ec4767bc4e..000000000000
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ /dev/null
@@ -1,60 +0,0 @@
-.. _cn_magicnumbers:
-
-.. include:: ../disclaimer-zh_CN.rst
-
-:Original: :ref:`Documentation/process/magic-number.rst <magicnumbers>`
-
-如果想评论或更新本文的内容,请直接发信到LKML。如果你使用英文交流有困难的话,也可
-以向中文版维护者求助。如果本翻译更新不及时或者翻译存在问题,请联系中文版维护者::
-
-        中文版维护者: 贾威威 Jia Wei Wei <harryxiyou@gmail.com>
-        中文版翻译者: 贾威威 Jia Wei Wei <harryxiyou@gmail.com>
-        中文版校译者: 贾威威 Jia Wei Wei <harryxiyou@gmail.com>
-
-Linux 魔术数
-============
-
-这个文件是有关当前使用的魔术值注册表。当你给一个结构添加了一个魔术值,你也应该把这个魔术值添加到这个文件,因为我们最好把用于各种结构的魔术值统一起来。
-
-使用魔术值来保护内核数据结构是一个非常好的主意。这就允许你在运行期检查(a)一个结构是否已经被攻击,或者(b)你已经给一个例行程序通过了一个错误的结构。后一种情况特别地有用---特别是当你通过一个空指针指向结构体的时候。tty源码,例如,经常通过特定驱动使用这种方法并且反复地排列特定方面的结构。
-
-使用魔术值的方法是在结构的开始处声明的,如下::
-
-        struct tty_ldisc {
-	        int	magic;
-        	...
-        };
-
-当你以后给内核添加增强功能的时候,请遵守这条规则!这样就会节省数不清的调试时间,特别是一些古怪的情况,例如,数组超出范围并且重新写了超出部分。遵守这个规则,‪这些情况可以被快速地,安全地避免。
-
-		Theodore Ts'o
-		  31 Mar 94
-
-给当前的Linux 2.1.55添加魔术表。
-
-		Michael Chastain
-		<mailto:mec@shout.net>
-		22 Sep 1997
-
-现在应该最新的Linux 2.1.112.因为在特性冻结期间,不能在2.2.x前改变任何东西。这些条目被数域所排序。
-
-		Krzysztof G.Baranowski
-	        <mailto: kgb@knm.org.pl>
-		29 Jul 1998
-
-更新魔术表到Linux 2.5.45。刚好越过特性冻结,但是有可能还会有一些新的魔术值在2.6.x之前融入到内核中。
-
-		Petr Baudis
-		<pasky@ucw.cz>
-		03 Nov 2002
-
-更新魔术表到Linux 2.5.74。
-
-		Fabian Frederick
-                <ffrederick@users.sourceforge.net>
-		09 Jul 2003
-
-===================== ================ ======================== ==========================================
-魔术数名              数字             结构                     文件
-===================== ================ ======================== ==========================================
-===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_TW/process/index.rst b/Documentation/translations/zh_TW/process/index.rst
index c5c59b4fd595..cb3dea0b78ab 100644
--- a/Documentation/translations/zh_TW/process/index.rst
+++ b/Documentation/translations/zh_TW/process/index.rst
@@ -54,7 +54,6 @@
 .. toctree::
    :maxdepth: 1
 
-   magic-number
    volatile-considered-harmful
 
 .. only::  subproject and html
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
deleted file mode 100644
index 0ccc60bee3d6..000000000000
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ /dev/null
@@ -1,63 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0
-
-.. _tw_magicnumbers:
-
-.. include:: ../disclaimer-zh_TW.rst
-
-:Original: :ref:`Documentation/process/magic-number.rst <magicnumbers>`
-
-如果想評論或更新本文的內容,請直接發信到LKML。如果你使用英文交流有困難的話,也可
-以向中文版維護者求助。如果本翻譯更新不及時或者翻譯存在問題,請聯繫中文版維護者::
-
-        中文版維護者: 賈威威 Jia Wei Wei <harryxiyou@gmail.com>
-        中文版翻譯者: 賈威威 Jia Wei Wei <harryxiyou@gmail.com>
-        中文版校譯者: 賈威威 Jia Wei Wei <harryxiyou@gmail.com>
-                      胡皓文 Hu Haowen <src.res@email.cn>
-
-Linux 魔術數
-============
-
-這個文件是有關當前使用的魔術值註冊表。當你給一個結構添加了一個魔術值,你也應該把這個魔術值添加到這個文件,因爲我們最好把用於各種結構的魔術值統一起來。
-
-使用魔術值來保護內核數據結構是一個非常好的主意。這就允許你在運行期檢查(a)一個結構是否已經被攻擊,或者(b)你已經給一個例行程序通過了一個錯誤的結構。後一種情況特別地有用---特別是當你通過一個空指針指向結構體的時候。tty源碼,例如,經常通過特定驅動使用這種方法並且反覆地排列特定方面的結構。
-
-使用魔術值的方法是在結構的開始處聲明的,如下::
-
-        struct tty_ldisc {
-	        int	magic;
-        	...
-        };
-
-當你以後給內核添加增強功能的時候,請遵守這條規則!這樣就會節省數不清的調試時間,特別是一些古怪的情況,例如,數組超出範圍並且重新寫了超出部分。遵守這個規則,‪這些情況可以被快速地,安全地避免。
-
-		Theodore Ts'o
-		  31 Mar 94
-
-給當前的Linux 2.1.55添加魔術表。
-
-		Michael Chastain
-		<mailto:mec@shout.net>
-		22 Sep 1997
-
-現在應該最新的Linux 2.1.112.因爲在特性凍結期間,不能在2.2.x前改變任何東西。這些條目被數域所排序。
-
-		Krzysztof G.Baranowski
-	        <mailto: kgb@knm.org.pl>
-		29 Jul 1998
-
-更新魔術表到Linux 2.5.45。剛好越過特性凍結,但是有可能還會有一些新的魔術值在2.6.x之前融入到內核中。
-
-		Petr Baudis
-		<pasky@ucw.cz>
-		03 Nov 2002
-
-更新魔術表到Linux 2.5.74。
-
-		Fabian Frederick
-                <ffrederick@users.sourceforge.net>
-		09 Jul 2003
-
-===================== ================ ======================== ==========================================
-魔術數名              數字             結構                     文件
-===================== ================ ======================== ==========================================
-===================== ================ ======================== ==========================================
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 05/15] coda: remove CODA_MAGIC
  2022-11-11  1:13 ` [PATCH v3 05/15] coda: remove CODA_MAGIC Ahelenia Ziemiańska
@ 2022-11-11  3:13   ` Jan Harkes
  0 siblings, 0 replies; 20+ messages in thread
From: Jan Harkes @ 2022-11-11  3:13 UTC (permalink / raw)
  To: Ahelenia Ziemiańska
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, Jiri Slaby, Jakub Kicinski, linux-doc,
	linux-kernel, linux-doc-tw-discuss

On Thu, Nov 10, 2022 at 08:14:01PM -0500, Ahelenia Ziemiańska wrote:
> We have largely moved away from this approach, and we have better
> debugging tooling nowadays: kill it.

I still haven't received a response to my earlier email asking what
better debug tooling you are talking about.

I gave an example of an older bug, which has been fixed, where a Coda
inode accidentally ending up in ext4 through an mmap path. This ended up
scribbling over a spinlock in the coda_inode_info data which resulted
into pretty random system lockups.

This was actually quite hard to track down because there is no check
that `file_inode(vma->vm_file)` actually returns the inode of another
file system. So I'd be interesting what this tooling is or how it can
be used to better catch/identify such cases.

So I actually like this type of magic because it can potentially catch
some cases that should never happen. We could rename it to from MAGIC to
ASSERT, we don't remove asserts from code because of better debug tooling.
Those random 4 bytes in a Coda internal structure are not in a hot path.

Jan


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 08/15] MIPS: IP27: remove KV_MAGIC
  2022-11-11  1:14 ` [PATCH v3 08/15] MIPS: IP27: remove KV_MAGIC Ahelenia Ziemiańska
@ 2022-11-11  5:40   ` Cye Borg
       [not found]   ` <CAD4NMuYU6+JYGwCwDqGW5bTN8Rgg4SwseH9JKzjPAzsujBuCEw@mail.gmail.com>
  1 sibling, 0 replies; 20+ messages in thread
From: Cye Borg @ 2022-11-11  5:40 UTC (permalink / raw)
  To: Ahelenia Ziemiańska
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Thomas Bogendoerfer, Greg Kroah-Hartman, Jiri Slaby,
	Jakub Kicinski, Bagas Sanjaya, linux-doc, linux-kernel,
	linux-doc-tw-discuss, linux-mips

Just asking:
This code in SGI seems to help bring online other CPUs.
- Does it use the firmware to do it?
- Is there a possibility that the magic number in this case is used by
the firmware?
- If yes: do we break multiprocessing on SGI if we delete this
"useless relic", which is not referenced in the linux code elsewhere?

Best regards:
Barnabás Virágh


On Fri, Nov 11, 2022 at 2:15 AM Ahelenia Ziemiańska
<nabijaczleweli@nabijaczleweli.xyz> wrote:
>
> It appeared in the original import of SGI code in 2.4.0-test3pre8 and
> has never been used anywhere.
>
> Reviewed-by: Bagas Sanjaya <bagasdotme@gmail.com>
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
> ---
>  Documentation/process/magic-number.rst                    | 1 -
>  Documentation/translations/it_IT/process/magic-number.rst | 1 -
>  Documentation/translations/zh_CN/process/magic-number.rst | 1 -
>  Documentation/translations/zh_TW/process/magic-number.rst | 1 -
>  arch/mips/include/asm/sn/klkernvars.h                     | 8 ++------
>  arch/mips/sgi-ip27/ip27-klnuma.c                          | 1 -
>  6 files changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
> index 7dada7abc733..d8ffbc21872e 100644
> --- a/Documentation/process/magic-number.rst
> +++ b/Documentation/process/magic-number.rst
> @@ -72,7 +72,6 @@ APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kerne
>  FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
>  SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
>  HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
> -KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
>  CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
>  QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
>  QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
> diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
> index f9634a04d349..0e59704aa617 100644
> --- a/Documentation/translations/it_IT/process/magic-number.rst
> +++ b/Documentation/translations/it_IT/process/magic-number.rst
> @@ -78,7 +78,6 @@ APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kerne
>  FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
>  SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
>  HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
> -KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
>  CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
>  QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
>  QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
> diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
> index 966b9e6b1a46..17a73661ef17 100644
> --- a/Documentation/translations/zh_CN/process/magic-number.rst
> +++ b/Documentation/translations/zh_CN/process/magic-number.rst
> @@ -61,7 +61,6 @@ APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kerne
>  FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
>  SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
>  HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
> -KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
>  CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
>  QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
>  QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
> diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
> index f3e87a6b3a01..9d44d49b93bf 100644
> --- a/Documentation/translations/zh_TW/process/magic-number.rst
> +++ b/Documentation/translations/zh_TW/process/magic-number.rst
> @@ -64,7 +64,6 @@ APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kerne
>  FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
>  SLIP_MAGIC            0x5302           slip                     ``drivers/net/slip.h``
>  HDLCDRV_MAGIC         0x5ac6e778       hdlcdrv_state            ``include/linux/hdlcdrv.h``
> -KV_MAGIC              0x5f4b565f       kernel_vars_s            ``arch/mips/include/asm/sn/klkernvars.h``
>  CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
>  QUEUE_MAGIC_FREE      0xf7e1c9a3       queue_entry              ``drivers/scsi/arm/queue.c``
>  QUEUE_MAGIC_USED      0xf7e1cc33       queue_entry              ``drivers/scsi/arm/queue.c``
> diff --git a/arch/mips/include/asm/sn/klkernvars.h b/arch/mips/include/asm/sn/klkernvars.h
> index ea6b21795163..93d5eb873255 100644
> --- a/arch/mips/include/asm/sn/klkernvars.h
> +++ b/arch/mips/include/asm/sn/klkernvars.h
> @@ -6,18 +6,14 @@
>  #ifndef __ASM_SN_KLKERNVARS_H
>  #define __ASM_SN_KLKERNVARS_H
>
> -#define KV_MAGIC_OFFSET                0x0
> -#define KV_RO_NASID_OFFSET     0x4
> -#define KV_RW_NASID_OFFSET     0x6
> -
> -#define KV_MAGIC               0x5f4b565f
> +#define KV_RO_NASID_OFFSET     0x0
> +#define KV_RW_NASID_OFFSET     0x2
>
>  #ifndef __ASSEMBLY__
>
>  #include <asm/sn/types.h>
>
>  typedef struct kern_vars_s {
> -       int             kv_magic;
>         nasid_t         kv_ro_nasid;
>         nasid_t         kv_rw_nasid;
>         unsigned long   kv_ro_baseaddr;
> diff --git a/arch/mips/sgi-ip27/ip27-klnuma.c b/arch/mips/sgi-ip27/ip27-klnuma.c
> index abd7a84df7dd..82bb7ac20ef8 100644
> --- a/arch/mips/sgi-ip27/ip27-klnuma.c
> +++ b/arch/mips/sgi-ip27/ip27-klnuma.c
> @@ -61,7 +61,6 @@ static __init void set_ktext_source(nasid_t client_nasid, nasid_t server_nasid)
>
>         KERN_VARS_ADDR(client_nasid) = (unsigned long)kvp;
>
> -       kvp->kv_magic = KV_MAGIC;
>         kvp->kv_ro_nasid = server_nasid;
>         kvp->kv_rw_nasid = master_nasid;
>         kvp->kv_ro_baseaddr = NODE_CAC_BASE(server_nasid);
> --
> 2.30.2

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 13/15] fcntl: remove FASYNC_MAGIC
  2022-11-11  1:14 ` [PATCH v3 13/15] fcntl: remove FASYNC_MAGIC Ahelenia Ziemiańska
@ 2022-11-11 10:00   ` Jeff Layton
  0 siblings, 0 replies; 20+ messages in thread
From: Jeff Layton @ 2022-11-11 10:00 UTC (permalink / raw)
  To: Ahelenia Ziemiańska
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Chuck Lever, Alexander Viro, Greg Kroah-Hartman, Jakub Kicinski,
	Jiri Slaby, linux-doc, linux-kernel, linux-doc-tw-discuss,
	linux-fsdevel

On Fri, 2022-11-11 at 02:14 +0100, Ahelenia Ziemiańska wrote:
> We have largely moved away from this approach, and we have better
> debugging instrumentation nowadays: kill it.
> 
> Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
> ---
>  Documentation/process/magic-number.rst                    | 1 -
>  Documentation/translations/it_IT/process/magic-number.rst | 1 -
>  Documentation/translations/zh_CN/process/magic-number.rst | 1 -
>  Documentation/translations/zh_TW/process/magic-number.rst | 1 -
>  fs/fcntl.c                                                | 6 ------
>  include/linux/fs.h                                        | 3 ---
>  6 files changed, 13 deletions(-)
> 
> diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
> index e59c707ec785..6e432917a5a8 100644
> --- a/Documentation/process/magic-number.rst
> +++ b/Documentation/process/magic-number.rst
> @@ -68,6 +68,5 @@ Changelog::
>  ===================== ================ ======================== ==========================================
>  Magic Name            Number           Structure                File
>  ===================== ================ ======================== ==========================================
> -FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
>  CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
>  ===================== ================ ======================== ==========================================
> diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
> index 37a539867b6f..7d4c117ac626 100644
> --- a/Documentation/translations/it_IT/process/magic-number.rst
> +++ b/Documentation/translations/it_IT/process/magic-number.rst
> @@ -74,6 +74,5 @@ Registro dei cambiamenti::
>  ===================== ================ ======================== ==========================================
>  Nome magico           Numero           Struttura                File
>  ===================== ================ ======================== ==========================================
> -FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
>  CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
>  ===================== ================ ======================== ==========================================
> diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
> index 8a3a3e872c52..c17e3f20440a 100644
> --- a/Documentation/translations/zh_CN/process/magic-number.rst
> +++ b/Documentation/translations/zh_CN/process/magic-number.rst
> @@ -57,6 +57,5 @@ Linux 魔术数
>  ===================== ================ ======================== ==========================================
>  魔术数名              数字             结构                     文件
>  ===================== ================ ======================== ==========================================
> -FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
>  CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
>  ===================== ================ ======================== ==========================================
> diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
> index 7ace7834f7f9..e2eeb74e7192 100644
> --- a/Documentation/translations/zh_TW/process/magic-number.rst
> +++ b/Documentation/translations/zh_TW/process/magic-number.rst
> @@ -60,6 +60,5 @@ Linux 魔術數
>  ===================== ================ ======================== ==========================================
>  魔術數名              數字             結構                     文件
>  ===================== ================ ======================== ==========================================
> -FASYNC_MAGIC          0x4601           fasync_struct            ``include/linux/fs.h``
>  CCB_MAGIC             0xf2691ad2       ccb                      ``drivers/scsi/ncr53c8xx.c``
>  ===================== ================ ======================== ==========================================
> diff --git a/fs/fcntl.c b/fs/fcntl.c
> index 146c9ab0cd4b..e366a3804108 100644
> --- a/fs/fcntl.c
> +++ b/fs/fcntl.c
> @@ -924,7 +924,6 @@ struct fasync_struct *fasync_insert_entry(int fd, struct file *filp, struct fasy
>  	}
>  
>  	rwlock_init(&new->fa_lock);
> -	new->magic = FASYNC_MAGIC;
>  	new->fa_file = filp;
>  	new->fa_fd = fd;
>  	new->fa_next = *fapp;
> @@ -988,11 +987,6 @@ static void kill_fasync_rcu(struct fasync_struct *fa, int sig, int band)
>  		struct fown_struct *fown;
>  		unsigned long flags;
>  
> -		if (fa->magic != FASYNC_MAGIC) {
> -			printk(KERN_ERR "kill_fasync: bad magic number in "
> -			       "fasync_struct!\n");
> -			return;
> -		}
>  		read_lock_irqsave(&fa->fa_lock, flags);
>  		if (fa->fa_file) {
>  			fown = &fa->fa_file->f_owner;
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index e654435f1651..acfd5db5341a 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1345,15 +1345,12 @@ static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)
>  
>  struct fasync_struct {
>  	rwlock_t		fa_lock;
> -	int			magic;
>  	int			fa_fd;
>  	struct fasync_struct	*fa_next; /* singly linked list */
>  	struct file		*fa_file;
>  	struct rcu_head		fa_rcu;
>  };
>  
> -#define FASYNC_MAGIC 0x4601
> -
>  /* SMP safe fasync helpers: */
>  extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
>  extern struct fasync_struct *fasync_insert_entry(int, struct file *, struct fasync_struct **, struct fasync_struct *);

Reviewed-by: Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 08/15] MIPS: IP27: remove KV_MAGIC
       [not found]   ` <CAD4NMuYU6+JYGwCwDqGW5bTN8Rgg4SwseH9JKzjPAzsujBuCEw@mail.gmail.com>
@ 2022-11-11 13:02     ` Thomas Bogendoerfer
  0 siblings, 0 replies; 20+ messages in thread
From: Thomas Bogendoerfer @ 2022-11-11 13:02 UTC (permalink / raw)
  To: Cye Borg
  Cc: Ahelenia Ziemiańska, Jonathan Corbet, Federico Vaga,
	Alex Shi, Yanteng Si, Hu Haowen, Greg Kroah-Hartman, Jiri Slaby,
	Jakub Kicinski, Bagas Sanjaya, linux-doc, linux-kernel,
	linux-doc-tw-discuss, linux-mips

On Fri, Nov 11, 2022 at 06:39:10AM +0100, Cye Borg wrote:
> Just asking:
> This code in SGI seems to help bring online other CPUs.
> - Does it use the firmware to do it?
> - Is there a possibility that the magic number in this case is used by the
> firmware?
> - If yes: do we break multiprocessing on SGI if we delete this "useless
> relic", which is not referenced in the linux code elsewhere?

this magic is just for a internal struct not used by firmware. It came
from IRIX code, but there is no point in keeping it

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2022-11-11 13:47 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11  1:13 [PATCH v3 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
2022-11-11  1:13 ` [PATCH v3 01/15] hamradio: baycom: remove BAYCOM_MAGIC Ahelenia Ziemiańska
2022-11-11  1:13 ` [PATCH v3 02/15] hamradio: yam: remove YAM_MAGIC Ahelenia Ziemiańska
2022-11-11  1:13 ` [PATCH v3 03/15] pcmcia: synclink_cs: remove MGSLPC_MAGIC Ahelenia Ziemiańska
2022-11-11  1:13 ` [PATCH v3 04/15] pcmcia: synclink_cs: remove dead paranoia_check, warn for missing line Ahelenia Ziemiańska
2022-11-11  1:13 ` [PATCH v3 05/15] coda: remove CODA_MAGIC Ahelenia Ziemiańska
2022-11-11  3:13   ` Jan Harkes
2022-11-11  1:14 ` [PATCH v3 06/15] Documentation: remove PG_MAGIC (not a magic number) Ahelenia Ziemiańska
2022-11-11  1:14 ` [PATCH v3 07/15] Documentation: remove NMI_MAGIC " Ahelenia Ziemiańska
2022-11-11  1:14 ` [PATCH v3 08/15] MIPS: IP27: remove KV_MAGIC Ahelenia Ziemiańska
2022-11-11  5:40   ` Cye Borg
     [not found]   ` <CAD4NMuYU6+JYGwCwDqGW5bTN8Rgg4SwseH9JKzjPAzsujBuCEw@mail.gmail.com>
2022-11-11 13:02     ` Thomas Bogendoerfer
2022-11-11  1:14 ` [PATCH v3 09/15] x86/APM: remove APM_BIOS_MAGIC Ahelenia Ziemiańska
2022-11-11  1:14 ` [PATCH v3 10/15] scsi: acorn: remove QUEUE_MAGIC_{FREE,USED} Ahelenia Ziemiańska
2022-11-11  1:14 ` [PATCH v3 11/15] hdlcdrv: remove HDLCDRV_MAGIC Ahelenia Ziemiańska
2022-11-11  1:14 ` [PATCH v3 12/15] drivers: net: slip: remove SLIP_MAGIC Ahelenia Ziemiańska
2022-11-11  1:14 ` [PATCH v3 13/15] fcntl: remove FASYNC_MAGIC Ahelenia Ziemiańska
2022-11-11 10:00   ` Jeff Layton
2022-11-11  1:14 ` [PATCH v3 14/15] scsi: ncr53c8xx: replace CCB_MAGIC with bool busy Ahelenia Ziemiańska
2022-11-11  1:14 ` [PATCH v3 15/15] Documentation: remove magic-number.rst Ahelenia Ziemiańska

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).