All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@stusta.de>
To: Adam Kropelin <akropel1@rochester.rr.com>
Cc: Paul.Clements@steeleye.com, linux-kernel@vger.kernel.org
Subject: [2.6 patch] drivers/block/nbd.c: don't defer compile error to runtime
Date: Sat, 3 Sep 2005 01:24:03 +0200	[thread overview]
Message-ID: <20050902232403.GD3657@stusta.de> (raw)
In-Reply-To: <20050902192047.A5879@mail.kroptech.com>

On Fri, Sep 02, 2005 at 07:20:47PM -0400, Adam Kropelin wrote:
> Adrian Bunk wrote:
> > If we can detect a problem at compile time, the compilation should
> > fail.
> 
> [...] 
> 
> >  	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();
> 
> 	BUILD_BUG_ON(sizeof(struct nbd_request) != 28);
> 
> ...perhaps?

Neat, I didn't know about this.

I didn't know about this.

> --Adam

cu
Adrian


<--  snip  -->


If we can detect a problem at compile time, the compilation should fail.


Signed-off-by: Adrian Bunk <bunk@stusta.de>

--- linux-2.6.13-mm1-full/drivers/block/nbd.c.old	2005-09-02 23:48:27.000000000 +0200
+++ linux-2.6.13-mm1-full/drivers/block/nbd.c	2005-09-03 01:08:04.000000000 +0200
@@ -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,


  reply	other threads:[~2005-09-02 23:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-02 22:10 [2.6 patch] drivers/block/nbd.c: don't defer compile error to runtime Adrian Bunk
2005-09-02 23:20 ` Adam Kropelin
2005-09-02 23:24   ` Adrian Bunk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-02-20 22:36 Adrian Bunk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050902232403.GD3657@stusta.de \
    --to=bunk@stusta.de \
    --cc=Paul.Clements@steeleye.com \
    --cc=akropel1@rochester.rr.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.