From 2be859d289a9e04199a29bd4b8d393a502ed4791 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Mon, 20 Apr 2020 23:48:23 +0430 Subject: [PATCH] minor, replace nullptr checks with implicit ones --- src/hb-blob.cc | 12 ++++++------ src/hb-cff-interp-common.hh | 6 +++--- src/hb-cff-interp-cs-common.hh | 4 ++-- src/hb-cff2-interp-cs.hh | 2 +- src/hb-directwrite.cc | 2 +- src/hb-ot-cff-common.hh | 18 ++++++++---------- src/hb-ot-cff1-table.hh | 26 +++++++++++++------------- src/hb-ot-cff2-table.hh | 6 +++--- src/hb-ot-layout.cc | 2 +- src/hb-ot-os2-unicode-ranges.hh | 3 +-- src/hb-subset-cff-common.cc | 6 +++--- src/hb-subset-cff-common.hh | 24 ++++++++++++------------ src/hb-subset-cff1.cc | 28 ++++++++++++++-------------- src/hb-subset-cff2.cc | 17 ++++++++--------- src/main.cc | 4 ++-- src/test-buffer-serialize.cc | 2 +- util/hb-subset.cc | 4 ++-- util/options.cc | 10 ++++++---- 18 files changed, 87 insertions(+), 89 deletions(-) diff --git a/src/hb-blob.cc b/src/hb-blob.cc index 24d8be754..fe2d8ef57 100644 --- a/src/hb-blob.cc +++ b/src/hb-blob.cc @@ -567,7 +567,7 @@ fail_without_close: HANDLE fd; unsigned int size = strlen (file_name) + 1; wchar_t * wchar_file_name = (wchar_t *) malloc (sizeof (wchar_t) * size); - if (unlikely (wchar_file_name == nullptr)) goto fail_without_close; + if (unlikely (!wchar_file_name)) goto fail_without_close; mbstowcs (wchar_file_name, file_name, size); #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) { @@ -601,14 +601,14 @@ fail_without_close: file->length = (unsigned long) GetFileSize (fd, nullptr); file->mapping = CreateFileMapping (fd, nullptr, PAGE_READONLY, 0, 0, nullptr); #endif - if (unlikely (file->mapping == nullptr)) goto fail; + if (unlikely (!file->mapping)) goto fail; #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) file->contents = (char *) MapViewOfFileFromApp (file->mapping, FILE_MAP_READ, 0, 0); #else file->contents = (char *) MapViewOfFile (file->mapping, FILE_MAP_READ, 0, 0, 0); #endif - if (unlikely (file->contents == nullptr)) goto fail; + if (unlikely (!file->contents)) goto fail; CloseHandle (fd); return hb_blob_create (file->contents, file->length, @@ -626,10 +626,10 @@ fail_without_close: It's used as a fallback for systems without mmap or to read from pipes */ unsigned long len = 0, allocated = BUFSIZ * 16; char *data = (char *) malloc (allocated); - if (unlikely (data == nullptr)) return hb_blob_get_empty (); + if (unlikely (!data)) return hb_blob_get_empty (); FILE *fp = fopen (file_name, "rb"); - if (unlikely (fp == nullptr)) goto fread_fail_without_close; + if (unlikely (!fp)) goto fread_fail_without_close; while (!feof (fp)) { @@ -640,7 +640,7 @@ fail_without_close: can cover files like that but lets limit our fallback reader */ if (unlikely (allocated > (2 << 28))) goto fread_fail; char *new_data = (char *) realloc (data, allocated); - if (unlikely (new_data == nullptr)) goto fread_fail; + if (unlikely (!new_data)) goto fread_fail; data = new_data; } diff --git a/src/hb-cff-interp-common.hh b/src/hb-cff-interp-common.hh index 274019cfb..91a9b7d0d 100644 --- a/src/hb-cff-interp-common.hh +++ b/src/hb-cff-interp-common.hh @@ -258,11 +258,11 @@ struct UnsizedByteStr : UnsizedArrayOf TRACE_SERIALIZE (this); HBUINT8 *p = c->allocate_size (1); - if (unlikely (p == nullptr)) return_trace (false); + if (unlikely (!p)) return_trace (false); *p = intOp; T *ip = c->allocate_size (T::static_size); - if (unlikely (ip == nullptr)) return_trace (false); + if (unlikely (!ip)) return_trace (false); return_trace (c->check_assign (*ip, value)); } @@ -539,7 +539,7 @@ struct op_serializer_t TRACE_SERIALIZE (this); HBUINT8 *d = c->allocate_size (opstr.str.length); - if (unlikely (d == nullptr)) return_trace (false); + if (unlikely (!d)) return_trace (false); memcpy (d, &opstr.str[0], opstr.str.length); return_trace (true); } diff --git a/src/hb-cff-interp-cs-common.hh b/src/hb-cff-interp-cs-common.hh index 336b18894..52d778ffe 100644 --- a/src/hb-cff-interp-cs-common.hh +++ b/src/hb-cff-interp-cs-common.hh @@ -76,12 +76,12 @@ struct biased_subrs_t void fini () {} - unsigned int get_count () const { return (subrs == nullptr) ? 0 : subrs->count; } + unsigned int get_count () const { return subrs ? subrs->count : 0; } unsigned int get_bias () const { return bias; } byte_str_t operator [] (unsigned int index) const { - if (unlikely ((subrs == nullptr) || index >= subrs->count)) + if (unlikely (!subrs || index >= subrs->count)) return Null (byte_str_t); else return (*subrs)[index]; diff --git a/src/hb-cff2-interp-cs.hh b/src/hb-cff2-interp-cs.hh index dc4e59548..8d9bb2689 100644 --- a/src/hb-cff2-interp-cs.hh +++ b/src/hb-cff2-interp-cs.hh @@ -90,7 +90,7 @@ struct cff2_cs_interp_env_t : cs_interp_env_t seen_blend = false; seen_vsindex_ = false; scalars.init (); - do_blend = (coords != nullptr) && num_coords && (varStore != &Null (CFF2VariationStore)); + do_blend = num_coords && coords && varStore->size; set_ivs (acc.privateDicts[fd].ivs); } diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc index efb2029ec..f2fce073e 100644 --- a/src/hb-directwrite.cc +++ b/src/hb-directwrite.cc @@ -635,7 +635,7 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan, bool isRightToLeft = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); const wchar_t localeName[20] = {0}; - if (buffer->props.language != nullptr) + if (buffer->props.language) mbstowcs ((wchar_t*) localeName, hb_language_to_string (buffer->props.language), 20); diff --git a/src/hb-ot-cff-common.hh b/src/hb-ot-cff-common.hh index c2b8812ec..b68ad8891 100644 --- a/src/hb-ot-cff-common.hh +++ b/src/hb-ot-cff-common.hh @@ -107,7 +107,7 @@ struct CFFIndex TRACE_SERIALIZE (this); unsigned int size = src.get_size (); CFFIndex *dest = c->allocate_size (size); - if (unlikely (dest == nullptr)) return_trace (false); + if (unlikely (!dest)) return_trace (false); memcpy (dest, &src, size); return_trace (true); } @@ -120,7 +120,7 @@ struct CFFIndex if (byteArray.length == 0) { COUNT *dest = c->allocate_min (); - if (unlikely (dest == nullptr)) return_trace (false); + if (unlikely (!dest)) return_trace (false); *dest = 0; } else @@ -146,9 +146,8 @@ struct CFFIndex for (unsigned int i = 0; i < byteArray.length; i++) { const byte_str_t &bs = byteArray[i]; - unsigned char *dest = c->allocate_size (bs.length); - if (unlikely (dest == nullptr)) - return_trace (false); + unsigned char *dest = c->allocate_size (bs.length); + if (unlikely (!dest)) return_trace (false); memcpy (dest, &bs[0], bs.length); } } @@ -178,7 +177,7 @@ struct CFFIndex if (it.len () == 0) { COUNT *dest = c->allocate_min (); - if (unlikely (dest == nullptr)) return_trace (false); + if (unlikely (!dest)) return_trace (false); *dest = 0; } else @@ -355,8 +354,7 @@ struct CFFIndexOf : CFFIndex for (unsigned int i = 0; i < dataArrayLen; i++) { TYPE *dest = c->start_embed (); - if (unlikely (dest == nullptr || - !dest->serialize (c, dataArray[i], param1, param2))) + if (unlikely (!dest || !dest->serialize (c, dataArray[i], param1, param2))) return_trace (false); } return_trace (true); @@ -390,7 +388,7 @@ struct Dict : UnsizedByteStr TRACE_SERIALIZE (this); /* serialize the opcode */ HBUINT8 *p = c->allocate_size (OpCode_Size (op)); - if (unlikely (p == nullptr)) return_trace (false); + if (unlikely (!p)) return_trace (false); if (Is_OpCode_ESC (op)) { *p = OpCode_escape; @@ -561,7 +559,7 @@ struct FDSelect TRACE_SERIALIZE (this); unsigned int size = src.get_size (num_glyphs); FDSelect *dest = c->allocate_size (size); - if (unlikely (dest == nullptr)) return_trace (false); + if (unlikely (!dest)) return_trace (false); memcpy (dest, &src, size); return_trace (true); } diff --git a/src/hb-ot-cff1-table.hh b/src/hb-ot-cff1-table.hh index e6352adc0..e1296c391 100644 --- a/src/hb-ot-cff1-table.hh +++ b/src/hb-ot-cff1-table.hh @@ -174,7 +174,7 @@ struct Encoding TRACE_SERIALIZE (this); unsigned int size = src.get_size (); Encoding *dest = c->allocate_size (size); - if (unlikely (dest == nullptr)) return_trace (false); + if (unlikely (!dest)) return_trace (false); memcpy (dest, &src, size); return_trace (true); } @@ -188,13 +188,13 @@ struct Encoding { TRACE_SERIALIZE (this); Encoding *dest = c->extend_min (*this); - if (unlikely (dest == nullptr)) return_trace (false); + if (unlikely (!dest)) return_trace (false); dest->format = format | ((supp_codes.length > 0) ? 0x80 : 0); switch (format) { case 0: { Encoding0 *fmt0 = c->allocate_size (Encoding0::min_size + HBUINT8::static_size * enc_count); - if (unlikely (fmt0 == nullptr)) return_trace (false); + if (unlikely (!fmt0)) return_trace (false); fmt0->nCodes () = enc_count; unsigned int glyph = 0; for (unsigned int i = 0; i < code_ranges.length; i++) @@ -211,7 +211,7 @@ struct Encoding case 1: { Encoding1 *fmt1 = c->allocate_size (Encoding1::min_size + Encoding1_Range::static_size * code_ranges.length); - if (unlikely (fmt1 == nullptr)) return_trace (false); + if (unlikely (!fmt1)) return_trace (false); fmt1->nRanges () = code_ranges.length; for (unsigned int i = 0; i < code_ranges.length; i++) { @@ -228,7 +228,7 @@ struct Encoding if (supp_codes.length) { CFF1SuppEncData *suppData = c->allocate_size (CFF1SuppEncData::min_size + SuppEncoding::static_size * supp_codes.length); - if (unlikely (suppData == nullptr)) return_trace (false); + if (unlikely (!suppData)) return_trace (false); suppData->nSups () = supp_codes.length; for (unsigned int i = 0; i < supp_codes.length; i++) { @@ -445,7 +445,7 @@ struct Charset TRACE_SERIALIZE (this); unsigned int size = src.get_size (num_glyphs); Charset *dest = c->allocate_size (size); - if (unlikely (dest == nullptr)) return_trace (false); + if (unlikely (!dest)) return_trace (false); memcpy (dest, &src, size); return_trace (true); } @@ -458,14 +458,14 @@ struct Charset { TRACE_SERIALIZE (this); Charset *dest = c->extend_min (*this); - if (unlikely (dest == nullptr)) return_trace (false); + if (unlikely (!dest)) return_trace (false); dest->format = format; switch (format) { case 0: { Charset0 *fmt0 = c->allocate_size (Charset0::min_size + HBUINT16::static_size * (num_glyphs - 1)); - if (unlikely (fmt0 == nullptr)) return_trace (false); + if (unlikely (!fmt0)) return_trace (false); unsigned int glyph = 0; for (unsigned int i = 0; i < sid_ranges.length; i++) { @@ -479,7 +479,7 @@ struct Charset case 1: { Charset1 *fmt1 = c->allocate_size (Charset1::min_size + Charset1_Range::static_size * sid_ranges.length); - if (unlikely (fmt1 == nullptr)) return_trace (false); + if (unlikely (!fmt1)) return_trace (false); for (unsigned int i = 0; i < sid_ranges.length; i++) { if (unlikely (!(sid_ranges[i].glyph <= 0xFF))) @@ -493,7 +493,7 @@ struct Charset case 2: { Charset2 *fmt2 = c->allocate_size (Charset2::min_size + Charset2_Range::static_size * sid_ranges.length); - if (unlikely (fmt2 == nullptr)) return_trace (false); + if (unlikely (!fmt2)) return_trace (false); for (unsigned int i = 0; i < sid_ranges.length; i++) { if (unlikely (!(sid_ranges[i].glyph <= 0xFFFF))) @@ -1148,7 +1148,7 @@ struct cff1 blob = nullptr; } - bool is_valid () const { return blob != nullptr; } + bool is_valid () const { return blob; } bool is_CID () const { return topDict.is_CID (); } bool is_predef_charset () const { return topDict.CharsetOffset <= ExpertSubsetCharset; } @@ -1288,7 +1288,7 @@ struct cff1 byte_str_t ustr = (*stringIndex)[sid - cff1_std_strings_length]; gname.name = hb_bytes_t ((const char*)ustr.arrayZ, ustr.length); } - if (unlikely (gname.name.arrayZ == nullptr)) { fini (); return; } + if (unlikely (!gname.name.arrayZ)) { fini (); return; } glyph_names.push (gname); } glyph_names.qsort (); @@ -1337,7 +1337,7 @@ struct cff1 gname_t key = { hb_bytes_t (name, len), 0 }; const gname_t *gname = glyph_names.bsearch (key); - if (gname == nullptr) return false; + if (!gname) return false; hb_codepoint_t gid = sid_to_glyph (gname->sid); if (!gid && gname->sid) return false; *glyph = gid; diff --git a/src/hb-ot-cff2-table.hh b/src/hb-ot-cff2-table.hh index 6af4efc99..075a0d4ef 100644 --- a/src/hb-ot-cff2-table.hh +++ b/src/hb-ot-cff2-table.hh @@ -55,7 +55,7 @@ struct CFF2FDSelect TRACE_SERIALIZE (this); unsigned int size = src.get_size (num_glyphs); CFF2FDSelect *dest = c->allocate_size (size); - if (unlikely (dest == nullptr)) return_trace (false); + if (unlikely (!dest)) return_trace (false); memcpy (dest, &src, size); return_trace (true); } @@ -123,7 +123,7 @@ struct CFF2VariationStore TRACE_SERIALIZE (this); unsigned int size_ = varStore->get_size (); CFF2VariationStore *dest = c->allocate_size (size_); - if (unlikely (dest == nullptr)) return_trace (false); + if (unlikely (!dest)) return_trace (false); memcpy (dest, varStore, size_); return_trace (true); } @@ -480,7 +480,7 @@ struct cff2 blob = nullptr; } - bool is_valid () const { return blob != nullptr; } + bool is_valid () const { return blob; } protected: hb_blob_t *blob; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 058caa2b9..f0efa7e8b 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1549,7 +1549,7 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face, do { glyphs_length = glyphs->get_population (); - if (lookups != nullptr) + if (lookups) { for (hb_codepoint_t lookup_index = HB_SET_VALUE_INVALID; hb_set_next (lookups, &lookup_index);) gsub.get_lookup (lookup_index).closure (&c, lookup_index); diff --git a/src/hb-ot-os2-unicode-ranges.hh b/src/hb-ot-os2-unicode-ranges.hh index a592e9663..9613d2d18 100644 --- a/src/hb-ot-os2-unicode-ranges.hh +++ b/src/hb-ot-os2-unicode-ranges.hh @@ -223,8 +223,7 @@ static unsigned int _hb_ot_os2_get_unicode_range_bit (hb_codepoint_t cp) { auto *range = hb_sorted_array (_hb_os2_unicode_ranges).bsearch (cp); - if (unlikely (range == nullptr)) return -1; - return range->bit; + return range ? range->bit : -1; } } /* namespace OT */ diff --git a/src/hb-subset-cff-common.cc b/src/hb-subset-cff-common.cc index 1536c0d18..04e1db24a 100644 --- a/src/hb-subset-cff-common.cc +++ b/src/hb-subset-cff-common.cc @@ -158,7 +158,7 @@ serialize_fdselect_3_4 (hb_serialize_context_t *c, { TRACE_SERIALIZE (this); FDSELECT3_4 *p = c->allocate_size (size); - if (unlikely (p == nullptr)) return_trace (false); + if (unlikely (!p)) return_trace (false); p->nRanges () = fdselect_ranges.length; for (unsigned int i = 0; i < fdselect_ranges.length; i++) { @@ -184,7 +184,7 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c, { TRACE_SERIALIZE (this); FDSelect *p = c->allocate_min (); - if (unlikely (p == nullptr)) return_trace (false); + if (unlikely (!p)) return_trace (false); p->format = fdselect_format; size -= FDSelect::min_size; @@ -194,7 +194,7 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c, case 0: { FDSelect0 *p = c->allocate_size (size); - if (unlikely (p == nullptr)) return_trace (false); + if (unlikely (!p)) return_trace (false); unsigned int range_index = 0; unsigned int fd = fdselect_ranges[range_index++].code; for (unsigned int i = 0; i < num_glyphs; i++) diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index 260da77a0..340089283 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -185,7 +185,7 @@ struct cff_font_dict_op_serializer_t : op_serializer_t else { HBUINT8 *d = c->allocate_size (opstr.str.length); - if (unlikely (d == nullptr)) return_trace (false); + if (unlikely (!d)) return_trace (false); memcpy (d, &opstr.str[0], opstr.str.length); } return_trace (true); @@ -461,19 +461,19 @@ struct subr_subset_param_t template void set_current_str (ENV &env, bool calling) { - parsed_cs_str_t *parsed_str = get_parsed_str_for_context (env.context); - if (likely (parsed_str != nullptr)) + parsed_cs_str_t *parsed_str = get_parsed_str_for_context (env.context); + if (unlikely (!parsed_str)) { - /* If the called subroutine is parsed partially but not completely yet, - * it must be because we are calling it recursively. - * Handle it as an error. */ - if (unlikely (calling && !parsed_str->is_parsed () && (parsed_str->values.length > 0))) - env.set_error (); - else - current_parsed_str = parsed_str; - } - else env.set_error (); + return; + } + /* If the called subroutine is parsed partially but not completely yet, + * it must be because we are calling it recursively. + * Handle it as an error. */ + if (unlikely (calling && !parsed_str->is_parsed () && (parsed_str->values.length > 0))) + env.set_error (); + else + current_parsed_str = parsed_str; } parsed_cs_str_t *current_parsed_str; diff --git a/src/hb-subset-cff1.cc b/src/hb-subset-cff1.cc index c84b3e2c6..3161faa2d 100644 --- a/src/hb-subset-cff1.cc +++ b/src/hb-subset-cff1.cc @@ -351,8 +351,8 @@ struct cff1_subr_subsetter_t : subr_subsetter_tset_parsed (); for (unsigned int i = 0; i < env.callStack.get_count (); i++) { - parsed_cs_str_t *parsed_str = param.get_parsed_str_for_context (env.callStack[i]); - if (likely (parsed_str != nullptr)) + parsed_cs_str_t *parsed_str = param.get_parsed_str_for_context (env.callStack[i]); + if (likely (parsed_str)) parsed_str->set_parsed (); else env.set_error (); @@ -715,7 +715,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c, if (plan.subset_localsubrs[i].length > 0) { CFF1Subrs *dest = c->start_embed (); - if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest)) return false; c->push (); if (likely (dest && dest->serialize (c, plan.subset_localsubrs[i]))) subrs_link = c->pop_pack (); @@ -726,8 +726,8 @@ static bool _serialize_cff1 (hb_serialize_context_t *c, } } - PrivateDict *pd = c->start_embed (); - if (unlikely (pd == nullptr)) return false; + PrivateDict *pd = c->start_embed (); + if (unlikely (!pd)) return false; c->push (); cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints); /* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */ @@ -751,7 +751,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c, /* CharStrings */ { CFF1CharStrings *cs = c->start_embed (); - if (unlikely (cs == nullptr)) return false; + if (unlikely (!cs)) return false; c->push (); if (likely (cs->serialize (c, plan.subset_charstrings))) plan.info.char_strings_link = c->pop_pack (); @@ -765,8 +765,8 @@ static bool _serialize_cff1 (hb_serialize_context_t *c, /* FDArray (FD Index) */ if (acc.fdArray != &Null (CFF1FDArray)) { - CFF1FDArray *fda = c->start_embed (); - if (unlikely (fda == nullptr)) return false; + CFF1FDArray *fda = c->start_embed (); + if (unlikely (!fda)) return false; c->push (); cff1_font_dict_op_serializer_t fontSzr; auto it = + hb_zip (+ hb_iter (plan.fontdicts_mod), + hb_iter (plan.fontdicts_mod)); @@ -798,7 +798,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c, if (plan.subset_charset) { Charset *dest = c->start_embed (); - if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest)) return false; c->push (); if (likely (dest->serialize (c, plan.subset_charset_format, @@ -816,7 +816,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c, if (plan.subset_encoding) { Encoding *dest = c->start_embed (); - if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest)) return false; c->push (); if (likely (dest->serialize (c, plan.subset_enc_format, @@ -835,7 +835,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c, { c->push (); CFF1Subrs *dest = c->start_embed (); - if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest)) return false; if (likely (dest->serialize (c, plan.subset_globalsubrs))) c->pop_pack (); else @@ -848,7 +848,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c, /* String INDEX */ { CFF1StringIndex *dest = c->start_embed (); - if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest)) return false; c->push (); if (likely (dest->serialize (c, *acc.stringIndex, plan.sidmap))) c->pop_pack (); @@ -876,7 +876,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c, { /* serialize singleton TopDict */ TopDict *top = c->start_embed (); - if (top == nullptr) return false; + if (!top) return false; c->push (); cff1_top_dict_op_serializer_t topSzr; unsigned top_size = 0; @@ -893,7 +893,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c, } /* serialize INDEX header for above */ CFF1Index *dest = c->start_embed (); - if (dest == nullptr) return false; + if (!dest) return false; return dest->serialize_header (c, hb_iter (hb_array_t (&top_size, 1))); } } diff --git a/src/hb-subset-cff2.cc b/src/hb-subset-cff2.cc index 02132d3d2..ef1ac39b6 100644 --- a/src/hb-subset-cff2.cc +++ b/src/hb-subset-cff2.cc @@ -354,7 +354,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c, if (plan.subset_localsubrs[i].length > 0) { CFF2Subrs *dest = c->start_embed (); - if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest)) return false; c->push (); if (likely (dest->serialize (c, plan.subset_localsubrs[i]))) subrs_link = c->pop_pack (); @@ -364,8 +364,8 @@ static bool _serialize_cff2 (hb_serialize_context_t *c, return false; } } - PrivateDict *pd = c->start_embed (); - if (unlikely (pd == nullptr)) return false; + PrivateDict *pd = c->start_embed (); + if (unlikely (!pd)) return false; c->push (); cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints); if (likely (pd->serialize (c, acc.privateDicts[i], privSzr, subrs_link))) @@ -385,7 +385,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c, /* CharStrings */ { CFF2CharStrings *cs = c->start_embed (); - if (unlikely (cs == nullptr)) return false; + if (unlikely (!cs)) return false; c->push (); if (likely (cs->serialize (c, plan.subset_charstrings))) plan.info.char_strings_link = c->pop_pack (); @@ -414,8 +414,8 @@ static bool _serialize_cff2 (hb_serialize_context_t *c, /* FDArray (FD Index) */ { c->push (); - CFF2FDArray *fda = c->start_embed (); - if (unlikely (fda == nullptr)) return false; + CFF2FDArray *fda = c->start_embed (); + if (unlikely (!fda)) return false; cff_font_dict_op_serializer_t fontSzr; auto it = + hb_zip (+ hb_iter (acc.fontDicts) @@ -432,8 +432,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c, { c->push (); CFF2VariationStore *dest = c->start_embed (); - if (unlikely (dest == nullptr)) return false; - if (unlikely (!dest->serialize (c, acc.varStore))) return false; + if (unlikely (!dest || !dest->serialize (c, acc.varStore))) return false; plan.info.var_store_link = c->pop_pack (); } @@ -456,7 +455,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c, /* global subrs */ { CFF2Subrs *dest = c->start_embed (); - if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest)) return false; return dest->serialize (c, plan.subset_globalsubrs); } } diff --git a/src/main.cc b/src/main.cc index 3cca88c40..70c88f8f6 100644 --- a/src/main.cc +++ b/src/main.cc @@ -279,7 +279,7 @@ static void dump_glyphs (hb_blob_t *blob, const char *font_name) { FILE *font_name_file = fopen ("out/.dumped_font_name", "r"); - if (font_name_file != nullptr) + if (font_name_file) { fprintf (stderr, "Purge or rename ./out folder if you like to run a glyph dump,\n" "run it like `rm -rf out && mkdir out && src/main font-file.ttf`\n"); @@ -287,7 +287,7 @@ dump_glyphs (hb_blob_t *blob, const char *font_name) } font_name_file = fopen ("out/.dumped_font_name", "w"); - if (font_name_file == nullptr) + if (!font_name_file) { fprintf (stderr, "./out is not accessible as a folder, create it please\n"); return; diff --git a/src/test-buffer-serialize.cc b/src/test-buffer-serialize.cc index 6393f0b7f..0e78099ce 100644 --- a/src/test-buffer-serialize.cc +++ b/src/test-buffer-serialize.cc @@ -68,7 +68,7 @@ main (int argc, char **argv) buf = hb_buffer_create (); char line[BUFSIZ], out[BUFSIZ]; - while (fgets (line, sizeof(line), stdin) != nullptr) + while (fgets (line, sizeof(line), stdin)) { hb_buffer_clear_contents (buf); diff --git a/util/hb-subset.cc b/util/hb-subset.cc index 008e4e619..253e48a0a 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -65,7 +65,7 @@ struct subset_consumer_t gunichar cp = g_utf8_get_char(c); hb_codepoint_t hb_cp = cp; hb_set_add (codepoints, hb_cp); - } while ((c = g_utf8_find_next_char(c, text + text_len)) != nullptr); + } while ((c = g_utf8_find_next_char(c, text + text_len))); } hb_bool_t @@ -74,7 +74,7 @@ struct subset_consumer_t const char* data = hb_blob_get_data (blob, &data_length); FILE *fp_out = fopen(output_file, "wb"); - if (fp_out == nullptr) { + if (!fp_out) { fprintf(stderr, "Unable to open output file\n"); return false; } diff --git a/util/options.cc b/util/options.cc index 0de87fbc2..41d4c328f 100644 --- a/util/options.cc +++ b/util/options.cc @@ -116,7 +116,7 @@ pre_parse (GOptionContext *context G_GNUC_UNUSED, { option_group_t *option_group = (option_group_t *) data; option_group->pre_parse (error); - return *error == nullptr; + return !*error; } static gboolean @@ -127,7 +127,7 @@ post_parse (GOptionContext *context G_GNUC_UNUSED, { option_group_t *option_group = static_cast(data); option_group->post_parse (error); - return *error == nullptr; + return !*error; } void @@ -152,10 +152,12 @@ option_parser_t::parse (int *argc, char ***argv) GError *parse_error = nullptr; if (!g_option_context_parse (context, argc, argv, &parse_error)) { - if (parse_error != nullptr) { + if (parse_error) + { fail (true, "%s", parse_error->message); //g_error_free (parse_error); - } else + } + else fail (true, "Option parse error"); } }