mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: viro@parcelfarce.linux.theplanet.co.uk
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel@vger.kernel.org, perex@suse.cz
Subject: Re: [RFC] ASLA design, depth of code review and lack thereof
Date: Sat, 5 Jun 2004 01:04:10 +0100	[thread overview]
Message-ID: <20040605000410.GT12308@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <Pine.LNX.4.58.0406041622480.7010@ppc970.osdl.org>

On Fri, Jun 04, 2004 at 04:29:20PM -0700, Linus Torvalds wrote:
> 
> 
> On Sat, 5 Jun 2004 viro@parcelfarce.linux.theplanet.co.uk wrote:
> >
> > 
> >         case SNDRV_PCM_FORMAT_FLOAT_BE:
> >         {
> >                 union {
> >                         float f;
> >                         u_int32_t i;
> >                 } u;
> >                 u.f = 0.0;
> > #ifdef SNDRV_LITTLE_ENDIAN
> >                 return bswap_32(u.i);
> > #else
> >                 return u.i;
> > #endif
> 
> So what I wonder about is why anybody does something like this in the 
> first place?
> 
> Any IEEE format architecture will make 0.0 be all-zeroes, last I saw. In
> fact, any architecture (IEEE or not) where that isn't true will have
> serious problems with floating point values in bss (hint: the bss isn't
> initialzed to 0.0, it's initialized to the bit pattern 0).
> 
> So what the above boils dow to is a very very strange way of writing
> 
> 	return 0;
> 
> and it has absolutely _zero_ to do with "little-endian" or anything else 
> for that matter.

	While we are at it, the function in question
(sound/core/pcm_misc.::snd_pcm_format_silence_64())
is a plain and simple array in disguise - it should've been

u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format)
{
	unsigned index = snd_enum_to_int(format); /* just a cast, hopefully */
	return index < SNDRV_PCM_FORMAT_LAST ? filler[index] : -EINVAL;
}

And -EINVAL here, BTW, is a broken interface - none of its callers are
checking for -EINVAL and that's a hell of an odd error value when normal
values can be all over the place in u64 anyway.

Looking at those callers, I'd say that this guy should be

unsigned char * find_filler(snd_pcm_format_t format)

and return a pointer to a (8-element) row in array of patterns.  Because
callers end up truncating the result and then filling a large area with
repeated copies.  All we get from use of u_int64_t is extra PITA with
endianness - memcpy from 1/2/4/8 element array is no less efficient than
assignment from u8/u16/u32/u64.

  reply	other threads:[~2004-06-05  0:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-04 23:08 viro
2004-06-04 23:14 ` viro
2004-06-04 23:29 ` Linus Torvalds
2004-06-05  0:04   ` viro [this message]
2004-06-07 13:14     ` Takashi Iwai
2004-06-07 22:40       ` viro
2004-06-08 12:49         ` Takashi Iwai
2004-06-07 13:10   ` Takashi Iwai
2004-06-04 23:37 ` Jeff Garzik
2004-06-07 13:24   ` Takashi Iwai
2004-06-07 13:47     ` Jeff Garzik
2004-06-07 13:57       ` Takashi Iwai
2004-06-07 14:05         ` Jeff Garzik
2004-06-07 14:12           ` Takashi Iwai
2004-06-07 14:18         ` Russell King
2004-06-08 13:27           ` Takashi Iwai

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=20040605000410.GT12308@parcelfarce.linux.theplanet.co.uk \
    --to=viro@parcelfarce.linux.theplanet.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@suse.cz \
    --cc=torvalds@osdl.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®