summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Holland-Moritz <mhx-perl@gmx.net>2006-04-23 06:47:04 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-04-24 08:01:32 +0000
commit9f616d01cdd2df6cb0ab278ef65f90a68ac10150 (patch)
treebe1f5fb27c2e50c89bcc807f082c9021d6aeffd6
parentc395bd6cbc645e80f929b5b4e285b43aa4366851 (diff)
downloadperl-9f616d01cdd2df6cb0ab278ef65f90a68ac10150.tar.gz
Ensure GvNAME doesn't return NULL
First patch from : Subject: Re: [PATCH] cleanup 212 warnings emitted by gcc-4.2 Message-ID: <20060423044704.6a383ee8@r2d2> p4raw-id: //depot/perl@27944
-rw-r--r--embed.fnc2
-rw-r--r--gv.c3
-rw-r--r--gv.h7
-rw-r--r--proto.h3
4 files changed, 9 insertions, 6 deletions
diff --git a/embed.fnc b/embed.fnc
index a1bc225406..cca7933dc0 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -283,7 +283,7 @@ Ap |void |gv_fullname |NN SV* sv|NN const GV* gv
Apmb |void |gv_fullname3 |NN SV* sv|NN const GV* gv|NULLOK const char* prefix
Ap |void |gv_fullname4 |NN SV* sv|NN const GV* gv|NULLOK const char* prefix|bool keepmain
Ap |void |gv_init |NN GV* gv|NULLOK HV* stash|NN const char* name|STRLEN len|int multi
-Ap |void |gv_name_set |NN GV* gv|NULLOK const char *name|U32 len|U32 flags
+Ap |void |gv_name_set |NN GV* gv|NN const char *name|U32 len|U32 flags
Apd |HV* |gv_stashpv |NN const char* name|I32 create
Apd |HV* |gv_stashpvn |NN const char* name|U32 namelen|I32 create
Apd |HV* |gv_stashsv |NULLOK SV* sv|I32 create
diff --git a/gv.c b/gv.c
index 9834b7a7cb..879a14bebb 100644
--- a/gv.c
+++ b/gv.c
@@ -2117,6 +2117,7 @@ Perl_gv_name_set(pTHX_ GV *gv, const char *name, U32 len, U32 flags)
dVAR;
U32 hash;
+ assert(name);
PERL_UNUSED_ARG(flags);
if (len > I32_MAX)
@@ -2127,7 +2128,7 @@ Perl_gv_name_set(pTHX_ GV *gv, const char *name, U32 len, U32 flags)
}
PERL_HASH(hash, name, len);
- GvNAME_HEK(gv) = name ? share_hek(name, len, hash) : 0;
+ GvNAME_HEK(gv) = share_hek(name, len, hash);
}
/*
diff --git a/gv.h b/gv.h
index ab745522e0..40139128b7 100644
--- a/gv.h
+++ b/gv.h
@@ -48,16 +48,17 @@ struct gp {
assert(SvTYPE(zzzz) == SVt_PVGV || SvTYPE(zzzz) >= SVt_PVLV); \
&(GvXPVGV(zzzz)->xiv_u.xivu_namehek); \
}))
+# define GvNAME_get(gv) ({ assert(GvNAME_HEK(gv)); HEK_KEY(GvNAME_HEK(gv)); })
+# define GvNAMELEN_get(gv) ({ assert(GvNAME_HEK(gv)); HEK_LEN(GvNAME_HEK(gv)); })
#else
# define GvGP(gv) ((gv)->sv_u.svu_gp)
# define GvFLAGS(gv) (GvXPVGV(gv)->xpv_cur)
# define GvSTASH(gv) (GvXPVGV(gv)->xnv_u.xgv_stash)
# define GvNAME_HEK(gv) (GvXPVGV(gv)->xiv_u.xivu_namehek)
+# define GvNAME_get(gv) HEK_KEY(GvNAME_HEK(gv))
+# define GvNAMELEN_get(gv) HEK_LEN(GvNAME_HEK(gv))
#endif
-#define GvNAME_get(gv) (GvNAME_HEK(gv) ? HEK_KEY(GvNAME_HEK(gv)) : NULL)
-#define GvNAMELEN_get(gv) (GvNAME_HEK(gv) ? HEK_LEN(GvNAME_HEK(gv)) : 0)
-
#define GvNAME(gv) GvNAME_get(gv)
#define GvNAMELEN(gv) GvNAMELEN_get(gv)
diff --git a/proto.h b/proto.h
index 54aecd96e8..6c7679b7b2 100644
--- a/proto.h
+++ b/proto.h
@@ -650,7 +650,8 @@ PERL_CALLCONV void Perl_gv_init(pTHX_ GV* gv, HV* stash, const char* name, STRLE
__attribute__nonnull__(pTHX_3);
PERL_CALLCONV void Perl_gv_name_set(pTHX_ GV* gv, const char *name, U32 len, U32 flags)
- __attribute__nonnull__(pTHX_1);
+ __attribute__nonnull__(pTHX_1)
+ __attribute__nonnull__(pTHX_2);
PERL_CALLCONV HV* Perl_gv_stashpv(pTHX_ const char* name, I32 create)
__attribute__nonnull__(pTHX_1);