mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eyal Lebedinsky <eyal@eyal.emu.id.au>
To: Marcelo Tosatti <marcelo.tosatti@cyclades.com>,
	linux-kernel list <linux-kernel@vger.kernel.org>
Subject: Re: Linux 2.4.26-rc2
Date: Fri, 16 Apr 2004 09:14:49 +1000	[thread overview]
Message-ID: <407F1769.9090700@eyal.emu.id.au> (raw)
In-Reply-To: <20040414121231.GA1406@logos.cnet>

Marcelo Tosatti wrote:
> The void pointer case in here its being done math on without any problem. What is the
> problem with void pointer math 

There is a problem regarding the C standard. The semantics of 'void *' are well defined
and only allow for limited use. Basically, you can cast any pointer to and from 'void *',
but nothing else.

Pointer math says that 'p+n' means "add to 'p' the value 'n*s' where 's' is the size
on the element that 'p' points to". A 'void *' does not have a defined element size
until it is cast. So, ANSI specifically does not allow any arithmetics on 'void *'.

Some compilers are forgiving and will invent an element size of '1' and allow the
math. We should not rely on such improper usage.

>> Maybe a cast is
>>called for in bh_kmap(), like:
>>	return (char *)kmap(bh->b_page) + bh_offset(bh);
> 
> 
> Hum, that would fix the warning but I dont see much reasoning behind it. 

It will not simply 'fix' the problem, this is one case where a cast is not
a bad thing (i.e. a cheat) but the correct thing to do.

--
Eyal Lebedinsky (eyal@eyal.emu.id.au) <http://samba.org/eyal/>

  parent reply	other threads:[~2004-04-15 23:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-06  0:42 Marcelo Tosatti
2004-04-06  1:57 ` Paul Mackerras
2004-04-08 19:11   ` Marcelo Tosatti
2004-04-11  6:20 ` Eyal Lebedinsky
     [not found]   ` <20040414121231.GA1406@logos.cnet>
2004-04-15 23:14     ` Eyal Lebedinsky [this message]
2004-04-16  0:58       ` Jeff Garzik

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=407F1769.9090700@eyal.emu.id.au \
    --to=eyal@eyal.emu.id.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.tosatti@cyclades.com \
    /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®