Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Cc: perex@perex.cz, tiwai@suse.de, linux-kernel@vger.kernel.org,
	linux-sound@vger.kernel.org
Subject: Re: [PATCH] sound: Add a generic result header
Date: Fri, 04 Dec 2026 17:45:46 +0100	[thread overview]
Message-ID: <87y0a5ro3p.wl-tiwai@suse.de> (raw)
In-Reply-To: <20261204114122.4465-1-sreekuttan2156239@gmail.com>

On Fri, 04 Dec 2026 12:41:22 +0100,
Sreeraj S Kurup wrote:
> 
> Add include/sound/snd_result.h to provide a common result
> structure for sound APIs.
> 
> Some sound APIs return unsigned int values but also use
> negative error codes to report failures. Since the return
> type is unsigned int, negative error codes are converted
> to unsigned values. This makes it hard to tell whether
> the returned value is an error or a valid result.
> 
> For example, returning -1 from an unsigned int function
> produces 0xffffffff, which could also be a valid value
> returned by the function. This makes it difficult to
> handle errors when the full range of unsigned values
> can be used.

I guess this is specific to HD-audio verbs, no?
Do we have multiple such cases?

> The new result structure uses a type field to identify
> what kind of value is stored. It supports error codes,
> signed integers, unsigned integers and pointers. Helper
> functions are provided to create each type of result.
> 
> This allows sound APIs to return errors and different
> kinds of values without using special values to indicate
> errors.
> 
> More result types and their corresponding helper
> functions can be added later as needed by other
> sound APIs.

I'd like to avoid this kind of things.  First off, having a union of a
pointer and integers can be dangerous, as they can be different sizes.
And, for a pointer, we have already solid macros to deal with the
special pointer values indicating errors.

Then the rest is signed/unsigned integer, and we need no special
macro.


thanks,

Takashi

  parent reply	other threads:[~2026-12-04 16:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 11:41 [PATCH] sound: Add a generic result header Sreeraj S Kurup
2026-12-04 11:48 ` sashiko-bot
2026-12-04 16:45 ` Takashi Iwai [this message]
2026-12-04 17:33   ` Sreeraj S Kurup

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=87y0a5ro3p.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=sreekuttan2156239@gmail.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