[pacman-dev] [PATCH v3 3/4] Declare alpm_pkg_get_(origin|reason) to return int

Andrew Gregory andrew.gregory.8 at gmail.com
Mon Oct 17 14:34:03 UTC 2016


On 10/17/16 at 10:17pm, Allan McRae wrote:
> On 13/10/16 06:13, ivy.foster at gmail.com wrote:
> > From: Ivy Foster <ivy.foster at gmail.com>
> > 
> > These functions can return -1 on error, which is not included in the
> > enumerated types they were declared to return.
> > 
> > Signed-off-by: Ivy Foster <ivy.foster at gmail.com>
> > ---
> 
> 
> be_local.c: In function ‘alpm_pkg_set_reason’:
> be_local.c:1124:30: error: comparison between signed and unsigned
> integer expressions [-Werror=sign-compare]
>   if(alpm_pkg_get_reason(pkg) == reason) {
>                               ^~
> 
> You can use --enable-warningflags to build with many of our current
> warning flags enabled.
> 
> Why change the return to an int and not add an UNKNOWN value to the enum
> (with value 0 or 1 << 30)?
> 
> Allan

The only way get_reason and get_origin return -1 is if pkg is NULL, so
UNKNOWN isn't really accurate.  We could add an ERROR value, but I was
hoping to avoid that.

apg


More information about the pacman-dev mailing list