mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andries Brouwer <aebr@win.tue.nl>
To: Anton Altaparmakov <aia21@cam.ac.uk>
Cc: Andries Brouwer <aebr@win.tue.nl>,
	FabF <fabian.frederick@skynet.be>, Andrew Morton <akpm@osdl.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2.6.7-mm1] MBR centralization
Date: Fri, 25 Jun 2004 11:39:48 +0200	[thread overview]
Message-ID: <20040625093948.GA4946@pclin040.win.tue.nl> (raw)
In-Reply-To: <1088152223.16286.9.camel@imp.csi.cam.ac.uk>

On Fri, Jun 25, 2004 at 09:30:24AM +0100, Anton Altaparmakov wrote:
> On Thu, 2004-06-24 at 14:06, Andries Brouwer wrote:
> > On Thu, Jun 24, 2004 at 08:38:52AM +0100, Anton Altaparmakov wrote:
> > > While I am at it, the above macro is even further optimized by moving the 
> > > endianness conversion to the constant so it is applied at compile time 
> > > rather than run time like so:
> > > 
> > > #define MSDOS_MBR(p)	((*(u16*)(p)) == __constant_cpu_to_le16(0xaa55))
> > 
> > I never understand why people want to do such things.
> > Cast a character pointer to u16*, possibly do a byteswap, etc.
> > What one wants is just
> > 
> > 	p[0] == 0x55 && p[1] == 0xaa
> 
> I would disagree.  Seeing something like "is_msdos_mbr(p)" it is
> immediately obvious what it means while seeing the "p[0] = 0x55 && p[1]
> = 0xaa" it is not obvious at all what it means.  IMO _any_ hardcoded
> value is a very bad thing

Ha Anton - you cannot read.
I complain about this strange casting, and you start talking about hardcoded
values (while you write 0xaa55 yourself). The current code is below - a good
name and no hardcoded constants and no strange casts.

Andries


#define MSDOS_LABEL_MAGIC1      0x55
#define MSDOS_LABEL_MAGIC2      0xAA

static inline int
msdos_magic_present(unsigned char *p)
{
        return (p[0] == MSDOS_LABEL_MAGIC1 && p[1] == MSDOS_LABEL_MAGIC2);
}

  parent reply	other threads:[~2004-06-25  9:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-23 21:15 FabF
2004-06-23 21:06 ` Andrew Morton
2004-06-23 22:04   ` FabF
2004-06-23 21:36 ` Andries Brouwer
2004-06-24  6:07   ` FabF
2004-06-24 12:57     ` Andries Brouwer
     [not found]     ` <Pine.LNX.4.60.0406240809280.29245@hermes-1.csi.cam.ac.uk>
     [not found]       ` <Pine.LNX.4.60.0406240829550.29245@hermes-1.csi.cam.ac.uk>
2004-06-24 13:06         ` Andries Brouwer
     [not found]           ` <1088152223.16286.9.camel@imp.csi.cam.ac.uk>
2004-06-25  9:39             ` Andries Brouwer [this message]
2004-06-24 15:10         ` FabF

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=20040625093948.GA4946@pclin040.win.tue.nl \
    --to=aebr@win.tue.nl \
    --cc=aia21@cam.ac.uk \
    --cc=akpm@osdl.org \
    --cc=fabian.frederick@skynet.be \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®