All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@kernel.org>
To: Ivo van Doorn <IvDoorn@gmail.com>,
	"John W. Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: drivers/net/wireless/rt2x00/: struct data_desc strangeness
Date: Sun, 14 Oct 2007 19:50:32 +0200	[thread overview]
Message-ID: <20071014175032.GI4211@stusta.de> (raw)

drivers/net/wireless/rt2x00/rt2x00ring.h contains the following:

<--  snip  -->

...
/*
 * data_desc
 * Each data entry also contains a descriptor which is used by the
 * device to determine what should be done with the packet and
 * what the current status is.
 * This structure is greatly simplified, but the descriptors
 * are basically a list of little endian 32 bit values.
 * Make the array by default 1 word big, this will allow us
 * to use sizeof() correctly.
 */
struct data_desc {
        __le32 word[1];
};
...
/*
 * TX/RX Descriptor access functions.
 */
static inline void rt2x00_desc_read(struct data_desc *desc,
                                    const u8 word, u32 *value)
{
        *value = le32_to_cpu(desc->word[word]);
}

static inline void rt2x00_desc_write(struct data_desc *desc,
                                     const u8 word, const u32 value)
{
        desc->word[word] = cpu_to_le32(value);
}
...

<--  snip  -->

I haven't checked whether it might work in all cases, but passing 
non-zero values as second parameter to rt2x00_desc_{read,write}()
(as is done in many cases) is even in the best case bad coding style.

Spotted by the Coverity checker.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


             reply	other threads:[~2007-10-14 17:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-14 17:50 Adrian Bunk [this message]
2007-10-14 19:06 ` drivers/net/wireless/rt2x00/: struct data_desc strangeness Ivo van Doorn
2007-10-23 19:43   ` Adrian Bunk
2007-10-23 20:13     ` Ivo van Doorn

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=20071014175032.GI4211@stusta.de \
    --to=bunk@kernel.org \
    --cc=IvDoorn@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.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 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.