This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fixing the cast for the result of (getgrent())->gr_gid
authorDavid M. Syzdek <david@syzdek.net>
Fri, 6 Mar 2009 23:03:40 +0000 (14:03 -0900)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sat, 7 Mar 2009 11:24:05 +0000 (12:24 +0100)
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 <corliss@corliss@digitalmages.com>.

Signed-off-by: David M. Syzdek <david@syzdek.net>
pp_sys.c

index 6bfdf35..f516e33 100644 (file)
--- 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