linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ftp.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christopher Li <sparse@chrisli.org>,
	Pavel Roskin <proski@gnu.org>,
	linux-sparse@vger.kernel.org
Subject: Re: Feature request - suppress warnings for system libraries
Date: Sat, 3 Feb 2007 00:30:30 +0000	[thread overview]
Message-ID: <20070203003030.GG10050@ftp.linux.org.uk> (raw)
In-Reply-To: <Pine.LNX.4.64.0702021522480.15057@woody.linux-foundation.org>

On Fri, Feb 02, 2007 at 03:25:20PM -0800, Linus Torvalds wrote:
> > Unlike __transparent_union__, restrict is at least a valid C...  It's not
> > that hard to handle, except for the shortage of bits for modifiers...
> 
> At worst, we could parse and ignore it.

*nod*

BTW, speaking of atrocities...

include/sound/asound.h:
typedef int __bitwise snd_pcm_hw_param_t;
#define SNDRV_PCM_HW_PARAM_ACCESS       ((__force snd_pcm_hw_param_t) 0) /* Access type */
#define SNDRV_PCM_HW_PARAM_FORMAT       ((__force snd_pcm_hw_param_t) 1) /* Format */
#define SNDRV_PCM_HW_PARAM_SUBFORMAT    ((__force snd_pcm_hw_param_t) 2) /* Subformat */
#define SNDRV_PCM_HW_PARAM_FIRST_MASK   SNDRV_PCM_HW_PARAM_ACCESS
#define SNDRV_PCM_HW_PARAM_LAST_MASK    SNDRV_PCM_HW_PARAM_SUBFORMAT

....

struct snd_pcm_hw_params {
        unsigned int flags;
        struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK -
                               SNDRV_PCM_HW_PARAM_FIRST_MASK + 1];


WTF is going on here?  We obviously do *not* treat that as bitwise.
Not only a blatant subtraction in the above; we do add that sucker to
pointer when accessing array elements.  Moreover, just look at the
other values:
#define SNDRV_PCM_HW_PARAM_SAMPLE_BITS  ((__force snd_pcm_hw_param_t) 8) /* Bits per sample */
#define SNDRV_PCM_HW_PARAM_FRAME_BITS   ((__force snd_pcm_hw_param_t) 9) /* Bits per frame */
#define SNDRV_PCM_HW_PARAM_CHANNELS     ((__force snd_pcm_hw_param_t) 10) /* Channels */
#define SNDRV_PCM_HW_PARAM_RATE         ((__force snd_pcm_hw_param_t) 11) /* Approx rate */  
#define SNDRV_PCM_HW_PARAM_PERIOD_TIME  ((__force snd_pcm_hw_param_t) 12) /* Approx distance between interrupts in us */
etc.

It's certainly not a bitwise type.  I'm not sure what the hell it's really
meant to be...   We have a similar turd in pm.h:
typedef int __bitwise suspend_state_t;

#define PM_SUSPEND_ON           ((__force suspend_state_t) 0)
#define PM_SUSPEND_STANDBY      ((__force suspend_state_t) 1)
#define PM_SUSPEND_MEM          ((__force suspend_state_t) 3)
#define PM_SUSPEND_DISK         ((__force suspend_state_t) 4)
#define PM_SUSPEND_MAX          ((__force suspend_state_t) 5)

with things like
./kernel/power/main.c:274:      for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {

using it.  Again, we have uses of that sucker as array size, for ordered
comparisons, for adding to pointer and for adding integer to it.  And
|, &, ^ and ~ are very definitely _not_ wanted on these values.

There probably is some legitimate set of checks the authors wanted, but
__bitwise__ sure as hell is not it...

  reply	other threads:[~2007-02-03  0:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-02 17:43 Feature request - suppress warnings for system libraries Pavel Roskin
2007-02-02 22:01 ` Christopher Li
2007-02-02 22:37   ` Pavel Roskin
2007-02-02 22:31     ` Christopher Li
2007-02-02 23:17       ` Al Viro
2007-02-02 23:03         ` Christopher Li
2007-02-02 23:25         ` Linus Torvalds
2007-02-03  0:30           ` Al Viro [this message]
2007-02-03  0:40             ` Al Viro

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=20070203003030.GG10050@ftp.linux.org.uk \
    --to=viro@ftp.linux.org.uk \
    --cc=linux-sparse@vger.kernel.org \
    --cc=proski@gnu.org \
    --cc=sparse@chrisli.org \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).