From: David M. Syzdek Date: Fri, 6 Mar 2009 23:03:40 +0000 (-0900) Subject: Fixing the cast for the result of (getgrent())->gr_gid X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f325df1b4578ec6fa0ef2a8b824f93439fcce816;p=p5sagit%2Fp5-mst-13.2.git Fixing the cast for the result of (getgrent())->gr_gid The gr_gid member of struct group is being cast as an int even if system uses an unsigned int. This patch tests for the use of an unsigned int for the gr_gid member and casts the value as appropiate. Created with Arthur Corliss . Signed-off-by: David M. Syzdek --- diff --git a/pp_sys.c b/pp_sys.c index 6bfdf35..f516e33 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -5328,7 +5328,11 @@ PP(pp_ggrent) PUSHs(sv); if (grent) { if (which == OP_GGRNAM) +#if Gid_t_sign <= 0 sv_setiv(sv, (IV)grent->gr_gid); +#else + sv_setuv(sv, (UV)grent->gr_gid); +#endif else sv_setpv(sv, grent->gr_name); } @@ -5344,7 +5348,11 @@ PP(pp_ggrent) PUSHs(sv_mortalcopy(&PL_sv_no)); #endif +#if Gid_t_sign <= 0 mPUSHi(grent->gr_gid); +#else + mPUSHu(grent->gr_gid); +#endif #if !(defined(_CRAYMPP) && defined(USE_REENTRANT_API)) /* In UNICOS/mk (_CRAYMPP) the multithreading