* [PATCH v2 00/15] magic-number.rst funeral rites
@ 2022-11-01 23:04 Ahelenia Ziemiańska
2022-11-01 23:05 ` [PATCH v2 01/15] hamradio: baycom: remove BAYCOM_MAGIC Ahelenia Ziemiańska
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-01 23:04 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: 4514 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)
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)
MIPS: IP27: clean out sn/nmi.h
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/include/asm/sn/nmi.h | 60 ------------
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 -
29 files changed, 29 insertions(+), 575 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] 5+ messages in thread
* [PATCH v2 01/15] hamradio: baycom: remove BAYCOM_MAGIC
2022-11-01 23:04 [PATCH v2 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
@ 2022-11-01 23:05 ` Ahelenia Ziemiańska
2022-11-01 23:05 ` [PATCH v2 02/15] hamradio: yam: remove YAM_MAGIC Ahelenia Ziemiańska
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-01 23:05 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: 6784 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/
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] 5+ messages in thread
* [PATCH v2 02/15] hamradio: yam: remove YAM_MAGIC
2022-11-01 23:04 [PATCH v2 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
2022-11-01 23:05 ` [PATCH v2 01/15] hamradio: baycom: remove BAYCOM_MAGIC Ahelenia Ziemiańska
@ 2022-11-01 23:05 ` Ahelenia Ziemiańska
2022-11-01 23:05 ` [PATCH v2 11/15] hdlcdrv: remove HDLCDRV_MAGIC Ahelenia Ziemiańska
2022-11-04 18:35 ` [PATCH v2 00/15] magic-number.rst funeral rites Jakub Kicinski
3 siblings, 0 replies; 5+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-01 23:05 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: 6479 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/
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] 5+ messages in thread
* [PATCH v2 11/15] hdlcdrv: remove HDLCDRV_MAGIC
2022-11-01 23:04 [PATCH v2 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
2022-11-01 23:05 ` [PATCH v2 01/15] hamradio: baycom: remove BAYCOM_MAGIC Ahelenia Ziemiańska
2022-11-01 23:05 ` [PATCH v2 02/15] hamradio: yam: remove YAM_MAGIC Ahelenia Ziemiańska
@ 2022-11-01 23:05 ` Ahelenia Ziemiańska
2022-11-04 18:35 ` [PATCH v2 00/15] magic-number.rst funeral rites Jakub Kicinski
3 siblings, 0 replies; 5+ messages in thread
From: Ahelenia Ziemiańska @ 2022-11-01 23:05 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, Kees Cook,
Yury Norov, Marc Kleine-Budde, Jason A. Donenfeld, Wolfram Sang,
linux-doc, linux-kernel, linux-doc-tw-discuss, linu
[-- Attachment #1: Type: text/plain, Size: 9037 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/
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] 5+ messages in thread
* Re: [PATCH v2 00/15] magic-number.rst funeral rites
2022-11-01 23:04 [PATCH v2 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
` (2 preceding siblings ...)
2022-11-01 23:05 ` [PATCH v2 11/15] hdlcdrv: remove HDLCDRV_MAGIC Ahelenia Ziemiańska
@ 2022-11-04 18:35 ` Jakub Kicinski
3 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2022-11-04 18:35 UTC (permalink / raw)
To: Ahelenia Ziemiańska
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
On Wed, 2 Nov 2022 00:04:54 +0100 Ahelenia Ziemiańska wrote:
> 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:
No idea how you want this to get merged, but FWIW you can add my
Acked-by: Jakub Kicinski <kuba@kernel.org>
to patches 1, 2, 11 and 12.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-11-04 18:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-01 23:04 [PATCH v2 00/15] magic-number.rst funeral rites Ahelenia Ziemiańska
2022-11-01 23:05 ` [PATCH v2 01/15] hamradio: baycom: remove BAYCOM_MAGIC Ahelenia Ziemiańska
2022-11-01 23:05 ` [PATCH v2 02/15] hamradio: yam: remove YAM_MAGIC Ahelenia Ziemiańska
2022-11-01 23:05 ` [PATCH v2 11/15] hdlcdrv: remove HDLCDRV_MAGIC Ahelenia Ziemiańska
2022-11-04 18:35 ` [PATCH v2 00/15] magic-number.rst funeral rites Jakub Kicinski
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).