From: Behdad Esfahbod Date: Thu, 22 Apr 2010 03:30:48 +0000 (-0400) Subject: Cleanup de-const-casting during sanitize X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=62c0fd75737a69721dbf29e773405a4c529f8b6d;p=platform%2Fupstream%2FlibHarfBuzzSharp.git Cleanup de-const-casting during sanitize --- diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh index c15fffd..0f3a363 100644 --- a/src/hb-open-file-private.hh +++ b/src/hb-open-file-private.hh @@ -150,7 +150,7 @@ struct TTCHeader TRACE_SANITIZE (); if (!SANITIZE (version)) return false; if (version.major < 1 || version.major > 2) return true; - return table.sanitize (SANITIZE_ARG, ConstCharP(this), ConstCharP(this)); + return table.sanitize (SANITIZE_ARG, CharP(this), CharP(this)); } private: diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index d81116d..b4bb1ee 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -43,7 +43,6 @@ /* Cast to const char *, to char *, or to char * dropping const-ness */ template inline const char * ConstCharP (const Type X) { return reinterpret_cast(X); } template inline char * CharP (Type X) { return reinterpret_cast(X); } -template inline char * DeConstCharP (const Type X) { return (char *) reinterpret_cast(X); } #define CONST_CAST(T,X,Ofs) (*(reinterpret_cast(ConstCharP(&(X)) + Ofs))) #define DECONST_CAST(T,X,Ofs) (*(reinterpret_cast((char *)ConstCharP(&(X)) + Ofs))) @@ -248,7 +247,7 @@ _hb_sanitize_edit (SANITIZE_ARG_DEF, #define SANITIZE(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG)) #define SANITIZE2(X,Y) (SANITIZE (X) && SANITIZE (Y)) -#define SANITIZE_THIS(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG, ConstCharP(this))) +#define SANITIZE_THIS(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG, CharP(this))) #define SANITIZE_THIS2(X,Y) (SANITIZE_THIS (X) && SANITIZE_THIS (Y)) #define SANITIZE_THIS3(X,Y,Z) (SANITIZE_THIS (X) && SANITIZE_THIS (Y) && SANITIZE_THIS(Z)) @@ -265,7 +264,7 @@ _hb_sanitize_edit (SANITIZE_ARG_DEF, #define NEUTER(Var, Val) \ (SANITIZE_OBJ (Var) && \ - _hb_sanitize_edit (SANITIZE_ARG, ConstCharP(&(Var)), sizeof (Var)) && \ + _hb_sanitize_edit (SANITIZE_ARG, CharP(&(Var)), sizeof (Var)) && \ ((Var).set (Val), true)) @@ -286,7 +285,7 @@ struct Sanitizer _hb_sanitize_init (&context, blob); - Type *t = &CAST (Type, *DeConstCharP(context.start), 0); + Type *t = &CAST (Type, * (char *) ConstCharP(context.start), 0); sane = t->sanitize (SANITIZE_ARG_INIT); if (sane) { @@ -480,26 +479,26 @@ struct GenericOffsetTo : OffsetType return CONST_CAST(Type, *ConstCharP(base), offset); } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { + inline bool sanitize (SANITIZE_ARG_DEF, void *base) { TRACE_SANITIZE (); if (!SANITIZE_SELF ()) return false; unsigned int offset = *this; if (HB_UNLIKELY (!offset)) return true; - return SANITIZE (CAST(Type, *DeConstCharP(base), offset)) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0); + return SANITIZE (CAST(Type, *CharP(base), offset)) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0); } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base, const void *base2) { + inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) { TRACE_SANITIZE (); if (!SANITIZE_SELF ()) return false; unsigned int offset = *this; if (HB_UNLIKELY (!offset)) return true; - return SANITIZE_BASE (CAST(Type, *DeConstCharP(base), offset), base2) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0); + return SANITIZE_BASE (CAST(Type, *CharP(base), offset), base2) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0); } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base, unsigned int user_data) { + inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) { TRACE_SANITIZE (); if (!SANITIZE_SELF ()) return false; unsigned int offset = *this; if (HB_UNLIKELY (!offset)) return true; - return SANITIZE_BASE (CAST(Type, *DeConstCharP(base), offset), user_data) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0); + return SANITIZE_BASE (CAST(Type, *CharP(base), offset), user_data) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0); } }; template @@ -559,7 +558,7 @@ struct GenericArrayOf return false; return true; } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { + inline bool sanitize (SANITIZE_ARG_DEF, void *base) { TRACE_SANITIZE (); if (!SANITIZE_GET_SIZE()) return false; unsigned int count = len; @@ -568,7 +567,7 @@ struct GenericArrayOf return false; return true; } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base, const void *base2) { + inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) { TRACE_SANITIZE (); if (!SANITIZE_GET_SIZE()) return false; unsigned int count = len; @@ -577,7 +576,7 @@ struct GenericArrayOf return false; return true; } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base, unsigned int user_data) { + inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) { TRACE_SANITIZE (); if (!SANITIZE_GET_SIZE()) return false; unsigned int count = len; @@ -623,11 +622,11 @@ struct OffsetListOf : OffsetArrayOf inline bool sanitize (SANITIZE_ARG_DEF) { TRACE_SANITIZE (); - return OffsetArrayOf::sanitize (SANITIZE_ARG, ConstCharP(this)); + return OffsetArrayOf::sanitize (SANITIZE_ARG, CharP(this)); } inline bool sanitize (SANITIZE_ARG_DEF, unsigned int user_data) { TRACE_SANITIZE (); - return OffsetArrayOf::sanitize (SANITIZE_ARG, ConstCharP(this), user_data); + return OffsetArrayOf::sanitize (SANITIZE_ARG, CharP(this), user_data); } }; diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index fd224b7..55ecc51 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -53,7 +53,7 @@ struct Record { static inline unsigned int get_size () { return sizeof (Record); } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { + inline bool sanitize (SANITIZE_ARG_DEF, void *base) { TRACE_SANITIZE (); return SANITIZE (tag) && SANITIZE_BASE (offset, base); } @@ -111,7 +111,7 @@ struct RecordListOf : RecordArrayOf inline bool sanitize (SANITIZE_ARG_DEF) { TRACE_SANITIZE (); - return RecordArrayOf::sanitize (SANITIZE_ARG, ConstCharP(this)); + return RecordArrayOf::sanitize (SANITIZE_ARG, CharP(this)); } }; diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh index da80d99..9dfda97 100644 --- a/src/hb-ot-layout-gpos-private.hh +++ b/src/hb-ot-layout-gpos-private.hh @@ -344,7 +344,7 @@ struct MarkRecord static inline unsigned int get_size () { return sizeof (MarkRecord); } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { + inline bool sanitize (SANITIZE_ARG_DEF, void *base) { TRACE_SANITIZE (); return SANITIZE_SELF () && SANITIZE_BASE (markAnchor, base); } @@ -602,7 +602,7 @@ struct PairPosFormat1 unsigned int len2 = valueFormat2.get_len (); if (!(SANITIZE_SELF () && SANITIZE_THIS (coverage) && - pairSet.sanitize (SANITIZE_ARG, ConstCharP(this), len1 + len2))) return false; + pairSet.sanitize (SANITIZE_ARG, CharP(this), len1 + len2))) return false; if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true; @@ -765,7 +765,7 @@ struct EntryExitRecord { static inline unsigned int get_size () { return sizeof (EntryExitRecord); } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { + inline bool sanitize (SANITIZE_ARG_DEF, void *base) { TRACE_SANITIZE (); return SANITIZE_BASE2 (entryAnchor, exitAnchor, base); } @@ -1050,7 +1050,7 @@ struct MarkBasePosFormat1 inline bool sanitize (SANITIZE_ARG_DEF) { TRACE_SANITIZE (); return SANITIZE_SELF () && SANITIZE_THIS2 (markCoverage, baseCoverage) && - SANITIZE_THIS (markArray) && baseArray.sanitize (SANITIZE_ARG, ConstCharP(this), classCount); + SANITIZE_THIS (markArray) && baseArray.sanitize (SANITIZE_ARG, CharP(this), classCount); } private: @@ -1171,7 +1171,7 @@ struct MarkLigPosFormat1 TRACE_SANITIZE (); return SANITIZE_SELF () && SANITIZE_THIS2 (markCoverage, ligatureCoverage) && - SANITIZE_THIS (markArray) && ligatureArray.sanitize (SANITIZE_ARG, ConstCharP(this), classCount); + SANITIZE_THIS (markArray) && ligatureArray.sanitize (SANITIZE_ARG, CharP(this), classCount); } private: @@ -1270,7 +1270,7 @@ struct MarkMarkPosFormat1 inline bool sanitize (SANITIZE_ARG_DEF) { TRACE_SANITIZE (); return SANITIZE_SELF () && SANITIZE_THIS2 (mark1Coverage, mark2Coverage) && - SANITIZE_THIS (mark1Array) && mark2Array.sanitize (SANITIZE_ARG, ConstCharP(this), classCount); + SANITIZE_THIS (mark1Array) && mark2Array.sanitize (SANITIZE_ARG, CharP(this), classCount); } private: