drivers/block/nbd.c: don't defer compile error to runtime
Subsystems (2)
PATCH 1/1 drivers/block/nbd.c: don't defer compile error to runtime
If we can detect a problem at compile time, the compilation should fail.
Signed-off-by Adrian Bunk <[email protected]>
drivers/block/nbd.c renamed from drivers/block/nbd.c.old +2 -2
@@ -644,8 +644,8 @@int i;if (sizeof (struct nbd_request ) !=28 ) { -printk (KERN_CRIT "nbd: sizeof nbd_request needs to be 28 in order to work!\n" ); -return -EIO ; +extern void nbd_request_wrong_size (void ); +nbd_request_wrong_size (); }if (nbds_max >MAX_NBD ) {
Quoted 2 lines · Adrian Bunk
If we can detect a problem at compile time, the compilation should fail.
[...]
drivers/block/nbd.c line 648
Quoted 5 lines
drivers/block/nbd.c renamed from drivers/block/nbd.c.old +2
-2if (sizeof (struct nbd_request ) !=28 ) { -printk (KERN_CRIT "nbd: sizeof nbd_request needs to be 28 in order to work!\n" ); -return -EIO ; +extern void nbd_request_wrong_size (void ); +nbd_request_wrong_size ();
BUILD_BUG_ON(sizeof(struct nbd_request) != 28);
...perhaps?
--Adam
PATCH 1/1 drivers/block/nbd.c: don't defer compile error to runtime
Quoted 14 lines · Adam Kropelin
Quoted 2 lines · Adrian Bunk
If we can detect a problem at compile time, the compilation should fail.
[...]
Review
Quoted 5 lines
(quoted diff) +2
-2if (sizeof(struct nbd_request) != 28) { - printk(KERN_CRIT "nbd: sizeof nbd_request needs to be 28 in order to work!\n" ); - return -EIO; + extern void nbd_request_wrong_size(void); + nbd_request_wrong_size();BUILD_BUG_ON(sizeof(struct nbd_request) != 28);
Quoted 1 line
...perhaps?
Neat, I didn't know about this.
I didn't know about this.
Quoted 1 line
--Adam
cu
Adrian
<-- snip -->
If we can detect a problem at compile time, the compilation should fail.
Signed-off-by Adrian Bunk <[email protected]>
drivers/block/nbd.c renamed from drivers/block/nbd.c.old +1 -4
@@ -643,10 +643,7 @@int err = -ENOMEM ;int i; -if (sizeof (struct nbd_request ) !=28 ) { -printk (KERN_CRIT "nbd: sizeof nbd_request needs to be 28 in order to work!\n" ); -return -EIO ; - } +BUILD_BUG_ON (sizeof (struct nbd_request ) !=28 );if (nbds_max >MAX_NBD ) { printk(KERN_CRIT "nbd: cannot allocate more than %u nbds; %u requested.\n", MAX_NBD,