shared: fix nm_errno_from_native() for negative values

We first need to map negative values to their positive form,
and then do the check for the reserved range.

Fixes: 18732c3493
This commit is contained in:
Thomas Haller 2019-01-31 16:11:06 +01:00
parent 047998f80a
commit 89d3c5242b

View file

@ -118,9 +118,9 @@ nm_errno_from_native (int errsv)
* are coerced to the special value NME_NATIVE_ERRNO, as they cannot
* otherwise be represented in nm-error number domain. */
if (errsv < 0) {
return G_UNLIKELY (errsv == G_MININT)
? NME_NATIVE_ERRNO
: -errsv;
if (G_UNLIKELY (errsv == G_MININT))
return NME_NATIVE_ERRNO;
errsv = -errsv;
}
return G_UNLIKELY ( errsv >= _NM_ERRNO_RESERVED_FIRST
&& errsv <= _NM_ERRNO_RESERVED_LAST)