All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Pavel Machek <pavel@ucw.cz>
Cc: Joe Perches <joe@perches.com>, Andy Whitcroft <apw@canonical.com>,
	Adil Mujeeb <mujeeb.adil@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] checkpatch: Emit a warning when decimal values are used
Date: Wed, 31 Oct 2012 15:49:08 -0700	[thread overview]
Message-ID: <20121031154908.5a1921eb.akpm@linux-foundation.org> (raw)
In-Reply-To: <20121031103703.GA12648@elf.ucw.cz>

On Wed, 31 Oct 2012 11:37:03 +0100
Pavel Machek <pavel@ucw.cz> wrote:

> Hi!
> 
> > Linux kernel doesn't like decimals, say so.
> 
> ?!
> 
> Linux surely supports decimal constants, like "100". Did you mean
> "octal"?
> 
> If you wanted to add warning for something... I never want to see
> 
> #define CRAPPY_EMBEDDED_REGISTER ((0x1) << (0))
> 
> again....

Joe means floating point.  I suggest that the patchset be reworked,
using s/decimal/float/g.


The kernel does have floating point constants, in various graphics
drivers, iirc.  They are used in places where the floatiness gets
handled at complation time.  Along the lines of:

	int foo = 1.1 * 2.2;

And I suppose that's an OK thing to do.  We could instead do

	int foo = 2;	/* 1.1 * 2.2 */

but that's taking away a programmer convenience for no good reason. 
It would be highly inconvenient if the "1.1" was in fact a #define in
some other file, or a Kconfig string.



That being said, I guess it's a worthwhile thing for checkpatch to warn
about.  Hopefully the programmer will say "well thanks, but I meant to
do that".

A much better solution would be to arrange for the kernel to fail to
compile (or to fail to link) if floats are used.  That way, people
could continue to use floats within their compile-time scalar
expressions without getting harrassed by checkpatch.  But I don't know
how to arrange this.

hm.

  reply	other threads:[~2012-10-31 22:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-31 10:13 [PATCH 0/3] checkpatch: Add support for decimal values Joe Perches
2012-10-31 10:13 ` [PATCH 1/3] checkpatch: Find hex constants as a single IDENT Joe Perches
2012-10-31 10:13 ` [PATCH 2/3] checkpatch: Add support for decimal constants Joe Perches
2012-10-31 10:13 ` [PATCH 3/3] checkpatch: Emit a warning when decimal values are used Joe Perches
2012-10-31 10:37   ` Pavel Machek
2012-10-31 22:49     ` Andrew Morton [this message]
2012-11-01  9:22       ` Pavel Machek
2012-11-01 11:43       ` Borislav Petkov

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=20121031154908.5a1921eb.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mujeeb.adil@gmail.com \
    --cc=pavel@ucw.cz \
    /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.