cast away a new warning

role.c: In function 'plnamesuffix':
role.c:1615:19: warning: operand of '?:' changes signedness from 'int' to 'unsigned int'
due to unsignedness of other operand [-Wsign-compare]
1615 |                 ? (int) (eptr - gp.plname)
                         ^~~~~~~~~~~~~~~~~~~~~~~~

Since Strlen() (actually hacklib's Strlen_ function) returns 'unsigned' for the
second operand of the '?:', the compiler was having to change the signedness
of the first operand '(int) (eptr - gp.plname)' to 'unsigned' and issuing the
warning.

Cast the result of Strlen() to int to make both operands of the '?:' the same
('signed').
This commit is contained in:
nhmall
2022-12-13 19:17:00 -05:00
parent 7096c68492
commit 2ee061e02d

View File

@@ -1613,7 +1613,7 @@ plnamesuffix(void)
contains a username with dash(es) in it and is usually 0 */
i = ((eptr = strchr(gp.plname + gp.plnamelen, '-')) != 0)
? (int) (eptr - gp.plname)
: Strlen(gp.plname);
: (int) Strlen(gp.plname);
/* look for plname[] in the 'genericusers' space-separated list */
if (findword(sysopt.genericusers, gp.plname, i, FALSE))
/* it's generic; remove it so that askname() will be called */