protobuf_c_message_unpack: 3031| 90.5k|{ 3032| 90.5k| ProtobufCMessage *rv; 3033| 90.5k| size_t rem = len; 3034| 90.5k| const uint8_t *at = data; 3035| 90.5k| const ProtobufCFieldDescriptor *last_field = desc->fields + 0; 3036| 90.5k| ScannedMember first_member_slab[1UL << 3037| 90.5k| FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2]; 3038| | 3039| | /* 3040| | * scanned_member_slabs[i] is an array of arrays of ScannedMember. 3041| | * The first slab (scanned_member_slabs[0] is just a pointer to 3042| | * first_member_slab), above. All subsequent slabs will be allocated 3043| | * using the allocator. 3044| | */ 3045| 90.5k| ScannedMember *scanned_member_slabs[MAX_SCANNED_MEMBER_SLAB + 1]; 3046| 90.5k| unsigned which_slab = 0; /* the slab we are currently populating */ 3047| 90.5k| unsigned in_slab_index = 0; /* number of members in the slab */ 3048| 90.5k| size_t n_unknown = 0; 3049| 90.5k| unsigned f; 3050| 90.5k| unsigned j; 3051| 90.5k| unsigned i_slab; 3052| 90.5k| unsigned last_field_index = 0; 3053| 90.5k| unsigned required_fields_bitmap_len; 3054| 90.5k| unsigned char required_fields_bitmap_stack[16]; 3055| 90.5k| unsigned char *required_fields_bitmap = required_fields_bitmap_stack; 3056| 90.5k| protobuf_c_boolean required_fields_bitmap_alloced = FALSE; ------------------ | | 54| 90.5k|#define FALSE 0 ------------------ 3057| | 3058| 90.5k| ASSERT_IS_MESSAGE_DESCRIPTOR(desc); ------------------ | | 124| 90.5k| assert((desc)->magic == PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC) ------------------ | Branch (3058:2): [True: 0, False: 90.5k] | Branch (3058:2): [True: 90.5k, False: 0] ------------------ 3059| | 3060| 90.5k| if (allocator == NULL) ------------------ | Branch (3060:6): [True: 2.04k, False: 88.5k] ------------------ 3061| 2.04k| allocator = &protobuf_c__allocator; 3062| | 3063| 90.5k| rv = do_alloc(allocator, desc->sizeof_message); 3064| 90.5k| if (!rv) ------------------ | Branch (3064:6): [True: 0, False: 90.5k] ------------------ 3065| 0| return (NULL); 3066| 90.5k| scanned_member_slabs[0] = first_member_slab; 3067| | 3068| 90.5k| required_fields_bitmap_len = (desc->n_fields + 7) / 8; 3069| 90.5k| if (required_fields_bitmap_len > sizeof(required_fields_bitmap_stack)) { ------------------ | Branch (3069:6): [True: 0, False: 90.5k] ------------------ 3070| 0| required_fields_bitmap = do_alloc(allocator, required_fields_bitmap_len); 3071| 0| if (!required_fields_bitmap) { ------------------ | Branch (3071:7): [True: 0, False: 0] ------------------ 3072| 0| do_free(allocator, rv); 3073| 0| return (NULL); 3074| 0| } 3075| 0| required_fields_bitmap_alloced = TRUE; ------------------ | | 53| 0|#define TRUE 1 ------------------ 3076| 0| } 3077| 90.5k| memset(required_fields_bitmap, 0, required_fields_bitmap_len); 3078| | 3079| | /* 3080| | * Generated code always defines "message_init". However, we provide a 3081| | * fallback for (1) users of old protobuf-c generated-code that do not 3082| | * provide the function, and (2) descriptors constructed from some other 3083| | * source (most likely, direct construction from the .proto file). 3084| | */ 3085| 90.5k| if (desc->message_init != NULL) ------------------ | Branch (3085:6): [True: 90.5k, False: 0] ------------------ 3086| 90.5k| protobuf_c_message_init(desc, rv); 3087| 0| else 3088| 0| message_init_generic(desc, rv); 3089| | 3090| 6.77M| while (rem > 0) { ------------------ | Branch (3090:9): [True: 6.68M, False: 90.0k] ------------------ 3091| 6.68M| uint32_t tag; 3092| 6.68M| uint8_t wire_type; 3093| 6.68M| size_t used = parse_tag_and_wiretype(rem, at, &tag, &wire_type); 3094| 6.68M| const ProtobufCFieldDescriptor *field; 3095| 6.68M| ScannedMember tmp; 3096| | 3097| 6.68M| if (used == 0) { ------------------ | Branch (3097:7): [True: 67, False: 6.68M] ------------------ 3098| 67| PROTOBUF_C_UNPACK_ERROR("error parsing tag/wiretype at offset %u", 3099| 67| (unsigned) (at - data)); 3100| 67| goto error_cleanup_during_scan; 3101| 67| } 3102| | /* 3103| | * \todo Consider optimizing for field[1].id == tag, if field[1] 3104| | * exists! 3105| | */ 3106| 6.68M| if (last_field == NULL || last_field->id != tag) { ------------------ | Branch (3106:7): [True: 0, False: 6.68M] | Branch (3106:29): [True: 906k, False: 5.77M] ------------------ 3107| | /* lookup field */ 3108| 906k| int field_index = 3109| 906k| int_range_lookup(desc->n_field_ranges, 3110| 906k| desc->field_ranges, 3111| 906k| tag); 3112| 906k| if (field_index < 0) { ------------------ | Branch (3112:8): [True: 644k, False: 262k] ------------------ 3113| 644k| field = NULL; 3114| 644k| n_unknown++; 3115| 644k| } else { 3116| 262k| field = desc->fields + field_index; 3117| 262k| last_field = field; 3118| 262k| last_field_index = field_index; 3119| 262k| } 3120| 5.77M| } else { 3121| 5.77M| field = last_field; 3122| 5.77M| } 3123| | 3124| 6.68M| if (field != NULL && field->label == PROTOBUF_C_LABEL_REQUIRED) ------------------ | Branch (3124:7): [True: 6.03M, False: 644k] | Branch (3124:24): [True: 882k, False: 5.15M] ------------------ 3125| 882k| REQUIRED_FIELD_BITMAP_SET(last_field_index); ------------------ | | 3022| 882k| (required_fields_bitmap[(index)/8] |= (1UL<<((index)%8))) ------------------ 3126| | 3127| 6.68M| at += used; 3128| 6.68M| rem -= used; 3129| 6.68M| tmp.tag = tag; 3130| 6.68M| tmp.wire_type = wire_type; 3131| 6.68M| tmp.field = field; 3132| 6.68M| tmp.data = at; 3133| 6.68M| tmp.length_prefix_len = 0; 3134| | 3135| 6.68M| switch (wire_type) { 3136| 6.04M| case PROTOBUF_C_WIRE_TYPE_VARINT: { ------------------ | Branch (3136:3): [True: 6.04M, False: 641k] ------------------ 3137| 6.04M| unsigned max_len = rem < 10 ? rem : 10; ------------------ | Branch (3137:23): [True: 82.1k, False: 5.95M] ------------------ 3138| 6.04M| unsigned i; 3139| | 3140| 6.51M| for (i = 0; i < max_len; i++) ------------------ | Branch (3140:16): [True: 6.51M, False: 77] ------------------ 3141| 6.51M| if ((at[i] & 0x80) == 0) ------------------ | Branch (3141:9): [True: 6.04M, False: 472k] ------------------ 3142| 6.04M| break; 3143| 6.04M| if (i == max_len) { ------------------ | Branch (3143:8): [True: 77, False: 6.04M] ------------------ 3144| 77| PROTOBUF_C_UNPACK_ERROR("unterminated varint at offset %u", 3145| 77| (unsigned) (at - data)); 3146| 77| goto error_cleanup_during_scan; 3147| 77| } 3148| 6.04M| tmp.len = i + 1; 3149| 6.04M| break; 3150| 6.04M| } 3151| 25.4k| case PROTOBUF_C_WIRE_TYPE_64BIT: ------------------ | Branch (3151:3): [True: 25.4k, False: 6.65M] ------------------ 3152| 25.4k| if (rem < 8) { ------------------ | Branch (3152:8): [True: 20, False: 25.4k] ------------------ 3153| 20| PROTOBUF_C_UNPACK_ERROR("too short after 64bit wiretype at offset %u", 3154| 20| (unsigned) (at - data)); 3155| 20| goto error_cleanup_during_scan; 3156| 20| } 3157| 25.4k| tmp.len = 8; 3158| 25.4k| break; 3159| 561k| case PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED: { ------------------ | Branch (3159:3): [True: 561k, False: 6.12M] ------------------ 3160| 561k| size_t pref_len; 3161| | 3162| 561k| tmp.len = scan_length_prefixed_data(rem, at, &pref_len); 3163| 561k| if (tmp.len == 0) { ------------------ | Branch (3163:8): [True: 159, False: 561k] ------------------ 3164| | /* NOTE: scan_length_prefixed_data calls UNPACK_ERROR */ 3165| 159| goto error_cleanup_during_scan; 3166| 159| } 3167| 561k| tmp.length_prefix_len = pref_len; 3168| 561k| break; 3169| 561k| } 3170| 54.3k| case PROTOBUF_C_WIRE_TYPE_32BIT: ------------------ | Branch (3170:3): [True: 54.3k, False: 6.62M] ------------------ 3171| 54.3k| if (rem < 4) { ------------------ | Branch (3171:8): [True: 21, False: 54.3k] ------------------ 3172| 21| PROTOBUF_C_UNPACK_ERROR("too short after 32bit wiretype at offset %u", 3173| 21| (unsigned) (at - data)); 3174| 21| goto error_cleanup_during_scan; 3175| 21| } 3176| 54.3k| tmp.len = 4; 3177| 54.3k| break; 3178| 125| default: ------------------ | Branch (3178:3): [True: 125, False: 6.68M] ------------------ 3179| 125| PROTOBUF_C_UNPACK_ERROR("unsupported tag %u at offset %u", 3180| 125| wire_type, (unsigned) (at - data)); 3181| 125| goto error_cleanup_during_scan; 3182| 6.68M| } 3183| | 3184| 6.68M| if (in_slab_index == (1UL << ------------------ | Branch (3184:7): [True: 5.07k, False: 6.67M] ------------------ 3185| 6.68M| (which_slab + FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2))) ------------------ | | 3010| 6.68M|#define FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2 4 ------------------ 3186| 5.07k| { 3187| 5.07k| size_t size; 3188| | 3189| 5.07k| in_slab_index = 0; 3190| 5.07k| if (which_slab == MAX_SCANNED_MEMBER_SLAB) { ------------------ | | 3017| 5.07k| (sizeof(unsigned int)*8 - 1 \ | | 3018| 5.07k| - BOUND_SIZEOF_SCANNED_MEMBER_LOG2 \ | | ------------------ | | | | 2097| 5.07k|#define BOUND_SIZEOF_SCANNED_MEMBER_LOG2 5 | | ------------------ | | 3019| 5.07k| - FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2) | | ------------------ | | | | 3010| 5.07k|#define FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2 4 | | ------------------ ------------------ | Branch (3190:8): [True: 0, False: 5.07k] ------------------ 3191| 0| PROTOBUF_C_UNPACK_ERROR("too many fields"); 3192| 0| goto error_cleanup_during_scan; 3193| 0| } 3194| 5.07k| which_slab++; 3195| 5.07k| size = sizeof(ScannedMember) 3196| 5.07k| << (which_slab + FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2); ------------------ | | 3010| 5.07k|#define FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2 4 ------------------ 3197| 5.07k| scanned_member_slabs[which_slab] = do_alloc(allocator, size); 3198| 5.07k| if (scanned_member_slabs[which_slab] == NULL) ------------------ | Branch (3198:8): [True: 0, False: 5.07k] ------------------ 3199| 0| goto error_cleanup_during_scan; 3200| 5.07k| } 3201| 6.68M| scanned_member_slabs[which_slab][in_slab_index++] = tmp; 3202| | 3203| 6.68M| if (field != NULL && field->label == PROTOBUF_C_LABEL_REPEATED) { ------------------ | Branch (3203:7): [True: 6.03M, False: 643k] | Branch (3203:24): [True: 5.12M, False: 917k] ------------------ 3204| 5.12M| size_t *n = STRUCT_MEMBER_PTR(size_t, rv, ------------------ | | 116| 5.12M| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 5.12M| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3205| 5.12M| field->quantifier_offset); 3206| 5.12M| if (wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED && ------------------ | Branch (3206:8): [True: 485k, False: 4.63M] ------------------ 3207| 485k| (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED) || ------------------ | Branch (3207:9): [True: 0, False: 485k] ------------------ 3208| 485k| is_packable_type(field->type))) ------------------ | Branch (3208:9): [True: 65.2k, False: 420k] ------------------ 3209| 65.2k| { 3210| 65.2k| size_t count; 3211| 65.2k| if (!count_packed_elements(field->type, ------------------ | Branch (3211:9): [True: 4, False: 65.2k] ------------------ 3212| 65.2k| tmp.len - 3213| 65.2k| tmp.length_prefix_len, 3214| 65.2k| tmp.data + 3215| 65.2k| tmp.length_prefix_len, 3216| 65.2k| &count)) 3217| 4| { 3218| 4| PROTOBUF_C_UNPACK_ERROR("counting packed elements"); 3219| 4| goto error_cleanup_during_scan; 3220| 4| } 3221| 65.2k| *n += count; 3222| 5.05M| } else { 3223| 5.05M| *n += 1; 3224| 5.05M| } 3225| 5.12M| } 3226| | 3227| 6.68M| at += tmp.len; 3228| 6.68M| rem -= tmp.len; 3229| 6.68M| } 3230| | 3231| | /* allocate space for repeated fields, also check that all required fields have been set */ 3232| 632k| for (f = 0; f < desc->n_fields; f++) { ------------------ | Branch (3232:14): [True: 542k, False: 90.0k] ------------------ 3233| 542k| const ProtobufCFieldDescriptor *field = desc->fields + f; 3234| 542k| if (field == NULL) { ------------------ | Branch (3234:7): [True: 0, False: 542k] ------------------ 3235| 0| continue; 3236| 0| } 3237| 542k| if (field->label == PROTOBUF_C_LABEL_REPEATED) { ------------------ | Branch (3237:7): [True: 119k, False: 423k] ------------------ 3238| 119k| size_t siz = 3239| 119k| sizeof_elt_in_repeated_array(field->type); 3240| 119k| size_t *n_ptr = 3241| 119k| STRUCT_MEMBER_PTR(size_t, rv, ------------------ | | 116| 119k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 119k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3242| 119k| field->quantifier_offset); 3243| 119k| if (*n_ptr != 0) { ------------------ | Branch (3243:8): [True: 4.64k, False: 114k] ------------------ 3244| 4.64k| unsigned n = *n_ptr; 3245| 4.64k| void *a; 3246| 4.64k| *n_ptr = 0; 3247| 4.64k| assert(rv->descriptor != NULL); ------------------ | Branch (3247:5): [True: 0, False: 4.64k] | Branch (3247:5): [True: 4.64k, False: 0] ------------------ 3248| 4.64k|#define CLEAR_REMAINING_N_PTRS() \ 3249| 4.64k| for(f++;f < desc->n_fields; f++) \ 3250| 4.64k| { \ 3251| 4.64k| field = desc->fields + f; \ 3252| 4.64k| if (field->label == PROTOBUF_C_LABEL_REPEATED) \ 3253| 4.64k| STRUCT_MEMBER (size_t, rv, field->quantifier_offset) = 0; \ 3254| 4.64k| } 3255| 4.64k| a = do_alloc(allocator, siz * n); 3256| 4.64k| if (!a) { ------------------ | Branch (3256:9): [True: 0, False: 4.64k] ------------------ 3257| 0| CLEAR_REMAINING_N_PTRS(); ------------------ | | 3249| 0| for(f++;f < desc->n_fields; f++) \ | | ------------------ | | | Branch (3249:23): [True: 0, False: 0] | | ------------------ | | 3250| 0| { \ | | 3251| 0| field = desc->fields + f; \ | | 3252| 0| if (field->label == PROTOBUF_C_LABEL_REPEATED) \ | | ------------------ | | | Branch (3252:23): [True: 0, False: 0] | | ------------------ | | 3253| 0| STRUCT_MEMBER (size_t, rv, field->quantifier_offset) = 0; \ | | ------------------ | | | | 107| 0| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | | | ------------------ | | | | | | 98| 0| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | | | ------------------ | | ------------------ | | 3254| 0| } ------------------ 3258| 0| goto error_cleanup; 3259| 0| } 3260| 4.64k| STRUCT_MEMBER(void *, rv, field->offset) = a; ------------------ | | 107| 4.64k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 4.64k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3261| 4.64k| } 3262| 423k| } else if (field->label == PROTOBUF_C_LABEL_REQUIRED) { ------------------ | Branch (3262:14): [True: 70.0k, False: 353k] ------------------ 3263| 70.0k| if (field->default_value == NULL && ------------------ | Branch (3263:8): [True: 70.0k, False: 0] ------------------ 3264| 70.0k| !REQUIRED_FIELD_BITMAP_IS_SET(f)) ------------------ | | 3025| 70.0k| (required_fields_bitmap[(index)/8] & (1UL<<((index)%8))) ------------------ | Branch (3264:8): [True: 25, False: 70.0k] ------------------ 3265| 25| { 3266| 25| CLEAR_REMAINING_N_PTRS(); ------------------ | | 3249| 150| for(f++;f < desc->n_fields; f++) \ | | ------------------ | | | Branch (3249:23): [True: 125, False: 25] | | ------------------ | | 3250| 125| { \ | | 3251| 125| field = desc->fields + f; \ | | 3252| 125| if (field->label == PROTOBUF_C_LABEL_REPEATED) \ | | ------------------ | | | Branch (3252:23): [True: 25, False: 100] | | ------------------ | | 3253| 125| STRUCT_MEMBER (size_t, rv, field->quantifier_offset) = 0; \ | | ------------------ | | | | 107| 25| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | | | ------------------ | | | | | | 98| 25| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | | | ------------------ | | ------------------ | | 3254| 125| } ------------------ 3267| 25| PROTOBUF_C_UNPACK_ERROR("message '%s': missing required field '%s'", 3268| 25| desc->name, field->name); 3269| 25| goto error_cleanup; 3270| 25| } 3271| 70.0k| } 3272| 542k| } 3273| 90.0k|#undef CLEAR_REMAINING_N_PTRS 3274| | 3275| | /* allocate space for unknown fields */ 3276| 90.0k| if (n_unknown) { ------------------ | Branch (3276:6): [True: 3.55k, False: 86.4k] ------------------ 3277| 3.55k| rv->unknown_fields = do_alloc(allocator, 3278| 3.55k| n_unknown * sizeof(ProtobufCMessageUnknownField)); 3279| 3.55k| if (rv->unknown_fields == NULL) ------------------ | Branch (3279:7): [True: 0, False: 3.55k] ------------------ 3280| 0| goto error_cleanup; 3281| 86.4k| } else { 3282| 86.4k| rv->unknown_fields = NULL; 3283| 86.4k| } 3284| | 3285| | /* do real parsing */ 3286| 184k| for (i_slab = 0; i_slab <= which_slab; i_slab++) { ------------------ | Branch (3286:19): [True: 94.6k, False: 89.5k] ------------------ 3287| 94.6k| unsigned max = (i_slab == which_slab) ? ------------------ | Branch (3287:18): [True: 89.9k, False: 4.65k] ------------------ 3288| 89.9k| in_slab_index : (1UL << (i_slab + 4)); 3289| 94.6k| ScannedMember *slab = scanned_member_slabs[i_slab]; 3290| | 3291| 4.28M| for (j = 0; j < max; j++) { ------------------ | Branch (3291:15): [True: 4.19M, False: 94.1k] ------------------ 3292| 4.19M| if (!parse_member(slab + j, rv, allocator)) { ------------------ | Branch (3292:8): [True: 504, False: 4.19M] ------------------ 3293| 504| PROTOBUF_C_UNPACK_ERROR("error parsing member %s of %s", 3294| 504| slab->field ? slab->field->name : "*unknown-field*", 3295| 504| desc->name); 3296| 504| goto error_cleanup; 3297| 504| } 3298| 4.19M| } 3299| 94.6k| } 3300| | 3301| | /* cleanup */ 3302| 93.5k| for (j = 1; j <= which_slab; j++) ------------------ | Branch (3302:14): [True: 4.03k, False: 89.5k] ------------------ 3303| 4.03k| do_free(allocator, scanned_member_slabs[j]); 3304| 89.5k| if (required_fields_bitmap_alloced) ------------------ | Branch (3304:6): [True: 0, False: 89.5k] ------------------ 3305| 0| do_free(allocator, required_fields_bitmap); 3306| 89.5k| return rv; 3307| | 3308| 529|error_cleanup: 3309| 529| protobuf_c_message_free_unpacked(rv, allocator); 3310| 1.26k| for (j = 1; j <= which_slab; j++) ------------------ | Branch (3310:14): [True: 737, False: 529] ------------------ 3311| 737| do_free(allocator, scanned_member_slabs[j]); 3312| 529| if (required_fields_bitmap_alloced) ------------------ | Branch (3312:6): [True: 0, False: 529] ------------------ 3313| 0| do_free(allocator, required_fields_bitmap); 3314| 529| return NULL; 3315| | 3316| 473|error_cleanup_during_scan: 3317| 473| do_free(allocator, rv); 3318| 777| for (j = 1; j <= which_slab; j++) ------------------ | Branch (3318:14): [True: 304, False: 473] ------------------ 3319| 304| do_free(allocator, scanned_member_slabs[j]); 3320| 473| if (required_fields_bitmap_alloced) ------------------ | Branch (3320:6): [True: 0, False: 473] ------------------ 3321| 0| do_free(allocator, required_fields_bitmap); 3322| | return NULL; 3323| 90.0k|} protobuf_c_message_free_unpacked: 3328| 90.0k|{ 3329| 90.0k| const ProtobufCMessageDescriptor *desc; 3330| 90.0k| unsigned f; 3331| | 3332| 90.0k| if (message == NULL) ------------------ | Branch (3332:6): [True: 0, False: 90.0k] ------------------ 3333| 0| return; 3334| | 3335| 90.0k| desc = message->descriptor; 3336| | 3337| 90.0k| ASSERT_IS_MESSAGE(message); ------------------ | | 127| 90.0k| ASSERT_IS_MESSAGE_DESCRIPTOR((message)->descriptor) | | ------------------ | | | | 124| 90.0k| assert((desc)->magic == PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC) | | ------------------ ------------------ | Branch (3337:2): [True: 0, False: 90.0k] | Branch (3337:2): [True: 90.0k, False: 0] ------------------ 3338| | 3339| 90.0k| if (allocator == NULL) ------------------ | Branch (3339:6): [True: 1.26k, False: 88.8k] ------------------ 3340| 1.26k| allocator = &protobuf_c__allocator; 3341| 90.0k| message->descriptor = NULL; 3342| 632k| for (f = 0; f < desc->n_fields; f++) { ------------------ | Branch (3342:14): [True: 542k, False: 90.0k] ------------------ 3343| 542k| if (0 != (desc->fields[f].flags & PROTOBUF_C_FIELD_FLAG_ONEOF) && ------------------ | Branch (3343:7): [True: 0, False: 542k] ------------------ 3344| 0| desc->fields[f].id != ------------------ | Branch (3344:7): [True: 0, False: 0] ------------------ 3345| 0| STRUCT_MEMBER(uint32_t, message, desc->fields[f].quantifier_offset)) ------------------ | | 107| 0| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 0| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3346| 0| { 3347| | /* This is not the selected oneof, skip it */ 3348| 0| continue; 3349| 0| } 3350| | 3351| 542k| if (desc->fields[f].label == PROTOBUF_C_LABEL_REPEATED) { ------------------ | Branch (3351:7): [True: 119k, False: 423k] ------------------ 3352| 119k| size_t n = STRUCT_MEMBER(size_t, ------------------ | | 107| 119k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 119k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3353| 119k| message, 3354| 119k| desc->fields[f].quantifier_offset); 3355| 119k| void *arr = STRUCT_MEMBER(void *, ------------------ | | 107| 119k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 119k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3356| 119k| message, 3357| 119k| desc->fields[f].offset); 3358| | 3359| 119k| if (arr != NULL) { ------------------ | Branch (3359:8): [True: 3.16k, False: 115k] ------------------ 3360| 3.16k| if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) { ------------------ | Branch (3360:9): [True: 48, False: 3.12k] ------------------ 3361| 48| unsigned i; 3362| 134k| for (i = 0; i < n; i++) ------------------ | Branch (3362:18): [True: 134k, False: 48] ------------------ 3363| 134k| do_free(allocator, ((char **) arr)[i]); 3364| 3.12k| } else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) { ------------------ | Branch (3364:16): [True: 97, False: 3.02k] ------------------ 3365| 97| unsigned i; 3366| 172k| for (i = 0; i < n; i++) ------------------ | Branch (3366:18): [True: 172k, False: 97] ------------------ 3367| 172k| do_free(allocator, ((ProtobufCBinaryData *) arr)[i].data); 3368| 3.02k| } else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) { ------------------ | Branch (3368:16): [True: 453, False: 2.57k] ------------------ 3369| 453| unsigned i; 3370| 70.4k| for (i = 0; i < n; i++) ------------------ | Branch (3370:18): [True: 69.9k, False: 453] ------------------ 3371| 69.9k| protobuf_c_message_free_unpacked( 3372| 69.9k| ((ProtobufCMessage **) arr)[i], 3373| 69.9k| allocator 3374| 69.9k| ); 3375| 453| } 3376| 3.16k| do_free(allocator, arr); 3377| 3.16k| } 3378| 423k| } else if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) { ------------------ | Branch (3378:14): [True: 18.3k, False: 405k] ------------------ 3379| 18.3k| char *str = STRUCT_MEMBER(char *, message, ------------------ | | 107| 18.3k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 18.3k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3380| 18.3k| desc->fields[f].offset); 3381| | 3382| 18.3k| if (str && str != desc->fields[f].default_value) ------------------ | Branch (3382:8): [True: 17.2k, False: 1.07k] | Branch (3382:15): [True: 919, False: 16.3k] ------------------ 3383| 919| do_free(allocator, str); 3384| 405k| } else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) { ------------------ | Branch (3384:14): [True: 36.6k, False: 368k] ------------------ 3385| 36.6k| void *data = STRUCT_MEMBER(ProtobufCBinaryData, message, ------------------ | | 107| 36.6k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 36.6k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3386| 36.6k| desc->fields[f].offset).data; 3387| 36.6k| const ProtobufCBinaryData *default_bd; 3388| | 3389| 36.6k| default_bd = desc->fields[f].default_value; 3390| 36.6k| if (data != NULL && ------------------ | Branch (3390:8): [True: 33.0k, False: 3.65k] ------------------ 3391| 33.0k| (default_bd == NULL || ------------------ | Branch (3391:9): [True: 0, False: 33.0k] ------------------ 3392| 33.0k| default_bd->data != data)) ------------------ | Branch (3392:9): [True: 1.00k, False: 32.0k] ------------------ 3393| 1.00k| { 3394| 1.00k| do_free(allocator, data); 3395| 1.00k| } 3396| 368k| } else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) { ------------------ | Branch (3396:14): [True: 140k, False: 228k] ------------------ 3397| 140k| ProtobufCMessage *sm; 3398| | 3399| 140k| sm = STRUCT_MEMBER(ProtobufCMessage *, message, ------------------ | | 107| 140k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 140k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3400| 140k| desc->fields[f].offset); 3401| 140k| if (sm && sm != desc->fields[f].default_value) ------------------ | Branch (3401:8): [True: 1.87k, False: 138k] | Branch (3401:14): [True: 1.87k, False: 0] ------------------ 3402| 1.87k| protobuf_c_message_free_unpacked(sm, allocator); 3403| 140k| } 3404| 542k| } 3405| | 3406| 624k| for (f = 0; f < message->n_unknown_fields; f++) ------------------ | Branch (3406:14): [True: 534k, False: 90.0k] ------------------ 3407| 534k| do_free(allocator, message->unknown_fields[f].data); 3408| 90.0k| if (message->unknown_fields != NULL) ------------------ | Branch (3408:6): [True: 3.55k, False: 86.5k] ------------------ 3409| 3.55k| do_free(allocator, message->unknown_fields); 3410| | 3411| 90.0k| do_free(allocator, message); 3412| 90.0k|} protobuf_c_message_init: 3417| 90.5k|{ 3418| 90.5k| descriptor->message_init((ProtobufCMessage *) (message)); 3419| 90.5k|} protobuf-c.c:system_alloc: 152| 787k|{ 153| 787k| (void)allocator_data; 154| 787k| return malloc(size); 155| 787k|} protobuf-c.c:system_free: 159| 787k|{ 160| 787k| (void)allocator_data; 161| 787k| free(data); 162| 787k|} protobuf-c.c:do_alloc: 166| 787k|{ 167| 787k| return allocator->alloc(allocator->allocator_data, size); 168| 787k|} protobuf-c.c:do_free: 172| 953k|{ 173| 953k| if (data != NULL) ------------------ | Branch (173:6): [True: 787k, False: 166k] ------------------ 174| 787k| allocator->free(allocator->allocator_data, data); 175| 953k|} protobuf-c.c:parse_tag_and_wiretype: 2067| 6.68M|{ 2068| 6.68M| unsigned max_rv = len > 5 ? 5 : len; ------------------ | Branch (2068:20): [True: 6.60M, False: 79.7k] ------------------ 2069| 6.68M| uint32_t tag = (data[0] & 0x7f) >> 3; 2070| 6.68M| unsigned shift = 4; 2071| 6.68M| unsigned rv; 2072| | 2073| | /* 0 is not a valid tag value */ 2074| 6.68M| if ((data[0] & 0xf8) == 0) { ------------------ | Branch (2074:6): [True: 40, False: 6.68M] ------------------ 2075| 40| return 0; 2076| 40| } 2077| | 2078| 6.68M| *wiretype_out = data[0] & 7; 2079| 6.68M| if ((data[0] & 0x80) == 0) { ------------------ | Branch (2079:6): [True: 5.83M, False: 845k] ------------------ 2080| 5.83M| *tag_out = tag; 2081| 5.83M| return 1; 2082| 5.83M| } 2083| 1.03M| for (rv = 1; rv < max_rv; rv++) { ------------------ | Branch (2083:15): [True: 1.03M, False: 27] ------------------ 2084| 1.03M| if (data[rv] & 0x80) { ------------------ | Branch (2084:7): [True: 185k, False: 845k] ------------------ 2085| 185k| tag |= (data[rv] & 0x7f) << shift; 2086| 185k| shift += 7; 2087| 845k| } else { 2088| 845k| tag |= data[rv] << shift; 2089| 845k| *tag_out = tag; 2090| 845k| return rv + 1; 2091| 845k| } 2092| 1.03M| } 2093| 27| return 0; /* error: bad header */ 2094| 845k|} protobuf-c.c:int_range_lookup: 2023| 906k|{ 2024| 906k| unsigned n; 2025| 906k| unsigned start; 2026| | 2027| 906k| if (n_ranges == 0) ------------------ | Branch (2027:6): [True: 0, False: 906k] ------------------ 2028| 0| return -1; 2029| 906k| start = 0; 2030| 906k| n = n_ranges; 2031| 1.08M| while (n > 1) { ------------------ | Branch (2031:9): [True: 184k, False: 900k] ------------------ 2032| 184k| unsigned mid = start + n / 2; 2033| | 2034| 184k| if (value < ranges[mid].start_value) { ------------------ | Branch (2034:7): [True: 41.4k, False: 142k] ------------------ 2035| 41.4k| n = mid - start; 2036| 142k| } else if (value >= ranges[mid].start_value + ------------------ | Branch (2036:14): [True: 137k, False: 5.61k] ------------------ 2037| 142k| (int) (ranges[mid + 1].orig_index - 2038| 142k| ranges[mid].orig_index)) 2039| 137k| { 2040| 137k| unsigned new_start = mid + 1; 2041| 137k| n = start + n - new_start; 2042| 137k| start = new_start; 2043| 137k| } else 2044| 5.61k| return (value - ranges[mid].start_value) + 2045| 5.61k| ranges[mid].orig_index; 2046| 184k| } 2047| 900k| if (n > 0) { ------------------ | Branch (2047:6): [True: 763k, False: 137k] ------------------ 2048| 763k| unsigned start_orig_index = ranges[start].orig_index; 2049| 763k| unsigned range_size = 2050| 763k| ranges[start + 1].orig_index - start_orig_index; 2051| | 2052| 763k| if (ranges[start].start_value <= value && ------------------ | Branch (2052:7): [True: 741k, False: 22.3k] ------------------ 2053| 741k| value < (int) (ranges[start].start_value + range_size)) ------------------ | Branch (2053:7): [True: 256k, False: 484k] ------------------ 2054| 256k| { 2055| 256k| return (value - ranges[start].start_value) + 2056| 256k| start_orig_index; 2057| 256k| } 2058| 763k| } 2059| 644k| return -1; 2060| 900k|} protobuf-c.c:scan_length_prefixed_data: 2112| 561k|{ 2113| 561k| unsigned hdr_max = len < 5 ? len : 5; ------------------ | Branch (2113:21): [True: 4.93k, False: 556k] ------------------ 2114| 561k| unsigned hdr_len; 2115| 561k| size_t val = 0; 2116| 561k| unsigned i; 2117| 561k| unsigned shift = 0; 2118| | 2119| 566k| for (i = 0; i < hdr_max; i++) { ------------------ | Branch (2119:14): [True: 566k, False: 41] ------------------ 2120| 566k| val |= ((size_t)data[i] & 0x7f) << shift; 2121| 566k| shift += 7; 2122| 566k| if ((data[i] & 0x80) == 0) ------------------ | Branch (2122:7): [True: 561k, False: 4.70k] ------------------ 2123| 561k| break; 2124| 566k| } 2125| 561k| if (i == hdr_max) { ------------------ | Branch (2125:6): [True: 41, False: 561k] ------------------ 2126| 41| PROTOBUF_C_UNPACK_ERROR("error parsing length for length-prefixed data"); 2127| 41| return 0; 2128| 41| } 2129| 561k| hdr_len = i + 1; 2130| 561k| *prefix_len_out = hdr_len; 2131| 561k| if (val > INT_MAX) { ------------------ | Branch (2131:6): [True: 6, False: 561k] ------------------ 2132| | // Protobuf messages should always be less than 2 GiB in size. 2133| | // We also want to return early here so that hdr_len + val does 2134| | // not overflow on 32-bit systems. 2135| 6| PROTOBUF_C_UNPACK_ERROR("length prefix of %lu is too large", 2136| 6| (unsigned long int)val); 2137| 6| return 0; 2138| 6| } 2139| 561k| if (hdr_len + val > len) { ------------------ | Branch (2139:6): [True: 112, False: 561k] ------------------ 2140| 112| PROTOBUF_C_UNPACK_ERROR("data too short after length-prefix of %lu", 2141| 112| (unsigned long int)val); 2142| 112| return 0; 2143| 112| } 2144| 561k| return hdr_len + val; 2145| 561k|} protobuf-c.c:is_packable_type: 2877| 903k|{ 2878| 903k| return 2879| 903k| type != PROTOBUF_C_TYPE_STRING && ------------------ | Branch (2879:3): [True: 597k, False: 306k] ------------------ 2880| 597k| type != PROTOBUF_C_TYPE_BYTES && ------------------ | Branch (2880:3): [True: 249k, False: 348k] ------------------ 2881| 249k| type != PROTOBUF_C_TYPE_MESSAGE; ------------------ | Branch (2881:3): [True: 106k, False: 142k] ------------------ 2882| 903k|} protobuf-c.c:count_packed_elements: 2358| 65.2k|{ 2359| 65.2k| switch (type) { 2360| 10.6k| case PROTOBUF_C_TYPE_SFIXED32: ------------------ | Branch (2360:2): [True: 10.6k, False: 54.5k] ------------------ 2361| 12.5k| case PROTOBUF_C_TYPE_FIXED32: ------------------ | Branch (2361:2): [True: 1.89k, False: 63.3k] ------------------ 2362| 26.0k| case PROTOBUF_C_TYPE_FLOAT: ------------------ | Branch (2362:2): [True: 13.5k, False: 51.6k] ------------------ 2363| 26.0k| if (len % 4 != 0) { ------------------ | Branch (2363:7): [True: 3, False: 26.0k] ------------------ 2364| 3| PROTOBUF_C_UNPACK_ERROR("length must be a multiple of 4 for fixed-length 32-bit types"); 2365| 3| return FALSE; ------------------ | | 54| 3|#define FALSE 0 ------------------ 2366| 3| } 2367| 26.0k| *count_out = len / 4; 2368| 26.0k| return TRUE; ------------------ | | 53| 26.0k|#define TRUE 1 ------------------ 2369| 771| case PROTOBUF_C_TYPE_SFIXED64: ------------------ | Branch (2369:2): [True: 771, False: 64.4k] ------------------ 2370| 1.56k| case PROTOBUF_C_TYPE_FIXED64: ------------------ | Branch (2370:2): [True: 791, False: 64.4k] ------------------ 2371| 3.08k| case PROTOBUF_C_TYPE_DOUBLE: ------------------ | Branch (2371:2): [True: 1.52k, False: 63.6k] ------------------ 2372| 3.08k| if (len % 8 != 0) { ------------------ | Branch (2372:7): [True: 1, False: 3.08k] ------------------ 2373| 1| PROTOBUF_C_UNPACK_ERROR("length must be a multiple of 8 for fixed-length 64-bit types"); 2374| 1| return FALSE; ------------------ | | 54| 1|#define FALSE 0 ------------------ 2375| 1| } 2376| 3.08k| *count_out = len / 8; 2377| 3.08k| return TRUE; ------------------ | | 53| 3.08k|#define TRUE 1 ------------------ 2378| 1.28k| case PROTOBUF_C_TYPE_ENUM: ------------------ | Branch (2378:2): [True: 1.28k, False: 63.9k] ------------------ 2379| 5.70k| case PROTOBUF_C_TYPE_INT32: ------------------ | Branch (2379:2): [True: 4.42k, False: 60.7k] ------------------ 2380| 10.9k| case PROTOBUF_C_TYPE_SINT32: ------------------ | Branch (2380:2): [True: 5.23k, False: 59.9k] ------------------ 2381| 13.7k| case PROTOBUF_C_TYPE_UINT32: ------------------ | Branch (2381:2): [True: 2.85k, False: 62.3k] ------------------ 2382| 14.9k| case PROTOBUF_C_TYPE_INT64: ------------------ | Branch (2382:2): [True: 1.18k, False: 64.0k] ------------------ 2383| 24.0k| case PROTOBUF_C_TYPE_SINT64: ------------------ | Branch (2383:2): [True: 9.02k, False: 56.1k] ------------------ 2384| 32.3k| case PROTOBUF_C_TYPE_UINT64: ------------------ | Branch (2384:2): [True: 8.32k, False: 56.8k] ------------------ 2385| 32.3k| *count_out = max_b128_numbers(len, data); 2386| 32.3k| return TRUE; ------------------ | | 53| 32.3k|#define TRUE 1 ------------------ 2387| 3.73k| case PROTOBUF_C_TYPE_BOOL: ------------------ | Branch (2387:2): [True: 3.73k, False: 61.4k] ------------------ 2388| 3.73k| *count_out = len; 2389| 3.73k| return TRUE; ------------------ | | 53| 3.73k|#define TRUE 1 ------------------ 2390| 0| case PROTOBUF_C_TYPE_STRING: ------------------ | Branch (2390:2): [True: 0, False: 65.2k] ------------------ 2391| 0| case PROTOBUF_C_TYPE_BYTES: ------------------ | Branch (2391:2): [True: 0, False: 65.2k] ------------------ 2392| 0| case PROTOBUF_C_TYPE_MESSAGE: ------------------ | Branch (2392:2): [True: 0, False: 65.2k] ------------------ 2393| 0| default: ------------------ | Branch (2393:2): [True: 0, False: 65.2k] ------------------ 2394| 0| PROTOBUF_C_UNPACK_ERROR("bad protobuf-c type %u for packed-repeated", type); 2395| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2396| 65.2k| } 2397| 65.2k|} protobuf-c.c:max_b128_numbers: 2149| 32.3k|{ 2150| 32.3k| size_t rv = 0; 2151| 12.2M| while (len--) ------------------ | Branch (2151:9): [True: 12.2M, False: 32.3k] ------------------ 2152| 12.2M| if ((*data++ & 0x80) == 0) ------------------ | Branch (2152:7): [True: 11.2M, False: 964k] ------------------ 2153| 11.2M| ++rv; 2154| 32.3k| return rv; 2155| 32.3k|} protobuf-c.c:sizeof_elt_in_repeated_array: 1238| 3.16M|{ 1239| 3.16M| switch (type) { ------------------ | Branch (1239:10): [True: 3.16M, False: 0] ------------------ 1240| 257k| case PROTOBUF_C_TYPE_SINT32: ------------------ | Branch (1240:2): [True: 257k, False: 2.91M] ------------------ 1241| 791k| case PROTOBUF_C_TYPE_INT32: ------------------ | Branch (1241:2): [True: 533k, False: 2.63M] ------------------ 1242| 801k| case PROTOBUF_C_TYPE_UINT32: ------------------ | Branch (1242:2): [True: 9.86k, False: 3.15M] ------------------ 1243| 808k| case PROTOBUF_C_TYPE_SFIXED32: ------------------ | Branch (1243:2): [True: 7.52k, False: 3.16M] ------------------ 1244| 812k| case PROTOBUF_C_TYPE_FIXED32: ------------------ | Branch (1244:2): [True: 4.05k, False: 3.16M] ------------------ 1245| 820k| case PROTOBUF_C_TYPE_FLOAT: ------------------ | Branch (1245:2): [True: 7.83k, False: 3.16M] ------------------ 1246| 932k| case PROTOBUF_C_TYPE_ENUM: ------------------ | Branch (1246:2): [True: 111k, False: 3.05M] ------------------ 1247| 932k| return 4; 1248| 21.3k| case PROTOBUF_C_TYPE_SINT64: ------------------ | Branch (1248:2): [True: 21.3k, False: 3.14M] ------------------ 1249| 1.78M| case PROTOBUF_C_TYPE_INT64: ------------------ | Branch (1249:2): [True: 1.76M, False: 1.40M] ------------------ 1250| 1.79M| case PROTOBUF_C_TYPE_UINT64: ------------------ | Branch (1250:2): [True: 9.88k, False: 3.15M] ------------------ 1251| 1.80M| case PROTOBUF_C_TYPE_SFIXED64: ------------------ | Branch (1251:2): [True: 5.47k, False: 3.16M] ------------------ 1252| 1.80M| case PROTOBUF_C_TYPE_FIXED64: ------------------ | Branch (1252:2): [True: 2.84k, False: 3.16M] ------------------ 1253| 1.81M| case PROTOBUF_C_TYPE_DOUBLE: ------------------ | Branch (1253:2): [True: 4.71k, False: 3.16M] ------------------ 1254| 1.81M| return 8; 1255| 37.7k| case PROTOBUF_C_TYPE_BOOL: ------------------ | Branch (1255:2): [True: 37.7k, False: 3.13M] ------------------ 1256| 37.7k| return sizeof(protobuf_c_boolean); 1257| 137k| case PROTOBUF_C_TYPE_STRING: ------------------ | Branch (1257:2): [True: 137k, False: 3.03M] ------------------ 1258| 209k| case PROTOBUF_C_TYPE_MESSAGE: ------------------ | Branch (1258:2): [True: 71.8k, False: 3.09M] ------------------ 1259| 209k| return sizeof(void *); 1260| 176k| case PROTOBUF_C_TYPE_BYTES: ------------------ | Branch (1260:2): [True: 176k, False: 2.99M] ------------------ 1261| 176k| return sizeof(ProtobufCBinaryData); 1262| 3.16M| } 1263| 0| PROTOBUF_C__ASSERT_NOT_REACHED(); ------------------ | | 56| 0|#define PROTOBUF_C__ASSERT_NOT_REACHED() assert(0) ------------------ | Branch (1263:2): [Folded, False: 0] | Branch (1263:2): [Folded, False: 0] ------------------ 1264| 0| return 0; 1265| 0|} protobuf-c.c:parse_member: 2888| 4.19M|{ 2889| 4.19M| const ProtobufCFieldDescriptor *field = scanned_member->field; 2890| 4.19M| void *member; 2891| | 2892| 4.19M| if (field == NULL) { ------------------ | Branch (2892:6): [True: 534k, False: 3.65M] ------------------ 2893| 534k| ProtobufCMessageUnknownField *ufield = 2894| 534k| message->unknown_fields + 2895| 534k| (message->n_unknown_fields++); 2896| 534k| ufield->tag = scanned_member->tag; 2897| 534k| ufield->wire_type = scanned_member->wire_type; 2898| 534k| ufield->len = scanned_member->len; 2899| 534k| ufield->data = do_alloc(allocator, scanned_member->len); 2900| 534k| if (ufield->data == NULL) ------------------ | Branch (2900:7): [True: 0, False: 534k] ------------------ 2901| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2902| 534k| memcpy(ufield->data, scanned_member->data, ufield->len); 2903| 534k| return TRUE; ------------------ | | 53| 534k|#define TRUE 1 ------------------ 2904| 534k| } 2905| 3.65M| member = (char *) message + field->offset; 2906| 3.65M| switch (field->label) { ------------------ | Branch (2906:10): [True: 3.65M, False: 0] ------------------ 2907| 584k| case PROTOBUF_C_LABEL_REQUIRED: ------------------ | Branch (2907:2): [True: 584k, False: 3.07M] ------------------ 2908| 584k| return parse_required_member(scanned_member, member, 2909| 584k| allocator, TRUE); ------------------ | | 53| 584k|#define TRUE 1 ------------------ 2910| 29.7k| case PROTOBUF_C_LABEL_OPTIONAL: ------------------ | Branch (2910:2): [True: 29.7k, False: 3.62M] ------------------ 2911| 29.7k| case PROTOBUF_C_LABEL_NONE: ------------------ | Branch (2911:2): [True: 0, False: 3.65M] ------------------ 2912| 29.7k| if (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_ONEOF)) { ------------------ | Branch (2912:7): [True: 0, False: 29.7k] ------------------ 2913| 0| return parse_oneof_member(scanned_member, member, 2914| 0| message, allocator); 2915| 29.7k| } else { 2916| 29.7k| return parse_optional_member(scanned_member, member, 2917| 29.7k| message, allocator); 2918| 29.7k| } 2919| 3.04M| case PROTOBUF_C_LABEL_REPEATED: ------------------ | Branch (2919:2): [True: 3.04M, False: 613k] ------------------ 2920| 3.04M| if (scanned_member->wire_type == ------------------ | Branch (2920:7): [True: 418k, False: 2.62M] ------------------ 2921| 3.04M| PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED && 2922| 418k| (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED) || ------------------ | Branch (2922:8): [True: 0, False: 418k] ------------------ 2923| 418k| is_packable_type(field->type))) ------------------ | Branch (2923:8): [True: 40.9k, False: 377k] ------------------ 2924| 40.9k| { 2925| 40.9k| return parse_packed_repeated_member(scanned_member, 2926| 40.9k| member, message); 2927| 3.00M| } else { 2928| 3.00M| return parse_repeated_member(scanned_member, 2929| 3.00M| member, message, 2930| 3.00M| allocator); 2931| 3.00M| } 2932| 3.65M| } 2933| 0| PROTOBUF_C__ASSERT_NOT_REACHED(); ------------------ | | 56| 0|#define PROTOBUF_C__ASSERT_NOT_REACHED() assert(0) ------------------ | Branch (2933:2): [Folded, False: 0] | Branch (2933:2): [Folded, False: 0] ------------------ 2934| 0| return 0; 2935| 0|} protobuf-c.c:parse_required_member: 2500| 3.61M|{ 2501| 3.61M| unsigned len = scanned_member->len; 2502| 3.61M| const uint8_t *data = scanned_member->data; 2503| 3.61M| uint8_t wire_type = scanned_member->wire_type; 2504| | 2505| 3.61M| switch (scanned_member->field->type) { ------------------ | Branch (2505:10): [True: 3.61M, False: 0] ------------------ 2506| 107k| case PROTOBUF_C_TYPE_ENUM: ------------------ | Branch (2506:2): [True: 107k, False: 3.50M] ------------------ 2507| 1.13M| case PROTOBUF_C_TYPE_INT32: ------------------ | Branch (2507:2): [True: 1.02M, False: 2.59M] ------------------ 2508| 1.13M| if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) ------------------ | Branch (2508:7): [True: 16, False: 1.13M] ------------------ 2509| 16| return FALSE; ------------------ | | 54| 16|#define FALSE 0 ------------------ 2510| 1.13M| *(int32_t *) member = parse_int32(len, data); 2511| 1.13M| return TRUE; ------------------ | | 53| 1.13M|#define TRUE 1 ------------------ 2512| 6.14k| case PROTOBUF_C_TYPE_UINT32: ------------------ | Branch (2512:2): [True: 6.14k, False: 3.61M] ------------------ 2513| 6.14k| if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) ------------------ | Branch (2513:7): [True: 3, False: 6.14k] ------------------ 2514| 3| return FALSE; ------------------ | | 54| 3|#define FALSE 0 ------------------ 2515| 6.14k| *(uint32_t *) member = parse_uint32(len, data); 2516| 6.14k| return TRUE; ------------------ | | 53| 6.14k|#define TRUE 1 ------------------ 2517| 252k| case PROTOBUF_C_TYPE_SINT32: ------------------ | Branch (2517:2): [True: 252k, False: 3.36M] ------------------ 2518| 252k| if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) ------------------ | Branch (2518:7): [True: 3, False: 252k] ------------------ 2519| 3| return FALSE; ------------------ | | 54| 3|#define FALSE 0 ------------------ 2520| 252k| *(int32_t *) member = unzigzag32(parse_uint32(len, data)); 2521| 252k| return TRUE; ------------------ | | 53| 252k|#define TRUE 1 ------------------ 2522| 917| case PROTOBUF_C_TYPE_SFIXED32: ------------------ | Branch (2522:2): [True: 917, False: 3.61M] ------------------ 2523| 1.58k| case PROTOBUF_C_TYPE_FIXED32: ------------------ | Branch (2523:2): [True: 668, False: 3.61M] ------------------ 2524| 2.14k| case PROTOBUF_C_TYPE_FLOAT: ------------------ | Branch (2524:2): [True: 558, False: 3.61M] ------------------ 2525| 2.14k| if (wire_type != PROTOBUF_C_WIRE_TYPE_32BIT) ------------------ | Branch (2525:7): [True: 39, False: 2.10k] ------------------ 2526| 39| return FALSE; ------------------ | | 54| 39|#define FALSE 0 ------------------ 2527| 2.10k| *(uint32_t *) member = parse_fixed_uint32(data); 2528| 2.10k| return TRUE; ------------------ | | 53| 2.10k|#define TRUE 1 ------------------ 2529| 1.76M| case PROTOBUF_C_TYPE_INT64: ------------------ | Branch (2529:2): [True: 1.76M, False: 1.85M] ------------------ 2530| 1.76M| case PROTOBUF_C_TYPE_UINT64: ------------------ | Branch (2530:2): [True: 3.17k, False: 3.61M] ------------------ 2531| 1.76M| if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) ------------------ | Branch (2531:7): [True: 2, False: 1.76M] ------------------ 2532| 2| return FALSE; ------------------ | | 54| 2|#define FALSE 0 ------------------ 2533| 1.76M| *(uint64_t *) member = parse_uint64(len, data); 2534| 1.76M| return TRUE; ------------------ | | 53| 1.76M|#define TRUE 1 ------------------ 2535| 12.6k| case PROTOBUF_C_TYPE_SINT64: ------------------ | Branch (2535:2): [True: 12.6k, False: 3.60M] ------------------ 2536| 12.6k| if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) ------------------ | Branch (2536:7): [True: 4, False: 12.5k] ------------------ 2537| 4| return FALSE; ------------------ | | 54| 4|#define FALSE 0 ------------------ 2538| 12.5k| *(int64_t *) member = unzigzag64(parse_uint64(len, data)); 2539| 12.5k| return TRUE; ------------------ | | 53| 12.5k|#define TRUE 1 ------------------ 2540| 3.22k| case PROTOBUF_C_TYPE_SFIXED64: ------------------ | Branch (2540:2): [True: 3.22k, False: 3.61M] ------------------ 2541| 3.73k| case PROTOBUF_C_TYPE_FIXED64: ------------------ | Branch (2541:2): [True: 506, False: 3.61M] ------------------ 2542| 5.48k| case PROTOBUF_C_TYPE_DOUBLE: ------------------ | Branch (2542:2): [True: 1.74k, False: 3.61M] ------------------ 2543| 5.48k| if (wire_type != PROTOBUF_C_WIRE_TYPE_64BIT) ------------------ | Branch (2543:7): [True: 40, False: 5.44k] ------------------ 2544| 40| return FALSE; ------------------ | | 54| 40|#define FALSE 0 ------------------ 2545| 5.44k| *(uint64_t *) member = parse_fixed_uint64(data); 2546| 5.44k| return TRUE; ------------------ | | 53| 5.44k|#define TRUE 1 ------------------ 2547| 32.8k| case PROTOBUF_C_TYPE_BOOL: ------------------ | Branch (2547:2): [True: 32.8k, False: 3.58M] ------------------ 2548| 32.8k| *(protobuf_c_boolean *) member = parse_boolean(len, data); 2549| 32.8k| return TRUE; ------------------ | | 53| 32.8k|#define TRUE 1 ------------------ 2550| 136k| case PROTOBUF_C_TYPE_STRING: { ------------------ | Branch (2550:2): [True: 136k, False: 3.48M] ------------------ 2551| 136k| char **pstr = member; 2552| 136k| unsigned pref_len = scanned_member->length_prefix_len; 2553| | 2554| 136k| if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) ------------------ | Branch (2554:7): [True: 11, False: 136k] ------------------ 2555| 11| return FALSE; ------------------ | | 54| 11|#define FALSE 0 ------------------ 2556| | 2557| 136k| if (maybe_clear && *pstr != NULL) { ------------------ | Branch (2557:7): [True: 1.53k, False: 134k] | Branch (2557:22): [True: 1.53k, False: 0] ------------------ 2558| 1.53k| const char *def = scanned_member->field->default_value; 2559| 1.53k| if (*pstr != def) ------------------ | Branch (2559:8): [True: 616, False: 919] ------------------ 2560| 616| do_free(allocator, *pstr); 2561| 1.53k| } 2562| 136k| *pstr = do_alloc(allocator, len - pref_len + 1); 2563| 136k| if (*pstr == NULL) ------------------ | Branch (2563:7): [True: 0, False: 136k] ------------------ 2564| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2565| 136k| memcpy(*pstr, data + pref_len, len - pref_len); 2566| 136k| (*pstr)[len - pref_len] = 0; 2567| 136k| return TRUE; ------------------ | | 53| 136k|#define TRUE 1 ------------------ 2568| 136k| } 2569| 180k| case PROTOBUF_C_TYPE_BYTES: { ------------------ | Branch (2569:2): [True: 180k, False: 3.43M] ------------------ 2570| 180k| ProtobufCBinaryData *bd = member; 2571| 180k| const ProtobufCBinaryData *def_bd; 2572| 180k| unsigned pref_len = scanned_member->length_prefix_len; 2573| | 2574| 180k| if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) ------------------ | Branch (2574:7): [True: 14, False: 180k] ------------------ 2575| 14| return FALSE; ------------------ | | 54| 14|#define FALSE 0 ------------------ 2576| | 2577| 180k| def_bd = scanned_member->field->default_value; 2578| 180k| if (maybe_clear && ------------------ | Branch (2578:7): [True: 8.21k, False: 172k] ------------------ 2579| 8.21k| bd->data != NULL && ------------------ | Branch (2579:7): [True: 7.29k, False: 922] ------------------ 2580| 7.29k| (def_bd == NULL || bd->data != def_bd->data)) ------------------ | Branch (2580:8): [True: 0, False: 7.29k] | Branch (2580:26): [True: 4.33k, False: 2.95k] ------------------ 2581| 4.33k| { 2582| 4.33k| do_free(allocator, bd->data); 2583| 4.33k| } 2584| 180k| if (len > pref_len) { ------------------ | Branch (2584:7): [True: 11.7k, False: 169k] ------------------ 2585| 11.7k| bd->data = do_alloc(allocator, len - pref_len); 2586| 11.7k| if (bd->data == NULL) ------------------ | Branch (2586:8): [True: 0, False: 11.7k] ------------------ 2587| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2588| 11.7k| memcpy(bd->data, data + pref_len, len - pref_len); 2589| 169k| } else { 2590| 169k| bd->data = NULL; 2591| 169k| } 2592| 180k| bd->len = len - pref_len; 2593| 180k| return TRUE; ------------------ | | 53| 180k|#define TRUE 1 ------------------ 2594| 180k| } 2595| 88.5k| case PROTOBUF_C_TYPE_MESSAGE: { ------------------ | Branch (2595:2): [True: 88.5k, False: 3.52M] ------------------ 2596| 88.5k| ProtobufCMessage **pmessage = member; 2597| 88.5k| ProtobufCMessage *subm; 2598| 88.5k| const ProtobufCMessage *def_mess; 2599| 88.5k| protobuf_c_boolean merge_successful = TRUE; ------------------ | | 53| 88.5k|#define TRUE 1 ------------------ 2600| 88.5k| unsigned pref_len = scanned_member->length_prefix_len; 2601| | 2602| 88.5k| if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) ------------------ | Branch (2602:7): [True: 9, False: 88.5k] ------------------ 2603| 9| return FALSE; ------------------ | | 54| 9|#define FALSE 0 ------------------ 2604| | 2605| 88.5k| def_mess = scanned_member->field->default_value; 2606| 88.5k| if (len >= pref_len) ------------------ | Branch (2606:7): [True: 88.5k, False: 0] ------------------ 2607| 88.5k| subm = protobuf_c_message_unpack(scanned_member->field->descriptor, 2608| 88.5k| allocator, 2609| 88.5k| len - pref_len, 2610| 88.5k| data + pref_len); 2611| 0| else 2612| 0| subm = NULL; 2613| | 2614| 88.5k| if (maybe_clear && ------------------ | Branch (2614:7): [True: 18.3k, False: 70.1k] ------------------ 2615| 18.3k| *pmessage != NULL && ------------------ | Branch (2615:7): [True: 16.4k, False: 1.90k] ------------------ 2616| 16.4k| *pmessage != def_mess) ------------------ | Branch (2616:7): [True: 16.4k, False: 0] ------------------ 2617| 16.4k| { 2618| 16.4k| if (subm != NULL) ------------------ | Branch (2618:8): [True: 16.4k, False: 24] ------------------ 2619| 16.4k| merge_successful = merge_messages(*pmessage, subm, allocator); 2620| | /* Delete the previous message */ 2621| 16.4k| protobuf_c_message_free_unpacked(*pmessage, allocator); 2622| 16.4k| } 2623| 88.5k| *pmessage = subm; 2624| 88.5k| if (subm == NULL || !merge_successful) ------------------ | Branch (2624:7): [True: 220, False: 88.2k] | Branch (2624:23): [True: 0, False: 88.2k] ------------------ 2625| 220| return FALSE; ------------------ | | 54| 220|#define FALSE 0 ------------------ 2626| 88.2k| return TRUE; ------------------ | | 53| 88.2k|#define TRUE 1 ------------------ 2627| 88.5k| } 2628| 3.61M| } 2629| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2630| 3.61M|} protobuf-c.c:parse_int32: 2419| 3.51M|{ 2420| 3.51M| return parse_uint32(len, data); 2421| 3.51M|} protobuf-c.c:parse_uint32: 2401| 12.1M|{ 2402| 12.1M| uint32_t rv = data[0] & 0x7f; 2403| 12.1M| if (len > 1) { ------------------ | Branch (2403:6): [True: 316k, False: 11.7M] ------------------ 2404| 316k| rv |= ((uint32_t) (data[1] & 0x7f) << 7); 2405| 316k| if (len > 2) { ------------------ | Branch (2405:7): [True: 119k, False: 196k] ------------------ 2406| 119k| rv |= ((uint32_t) (data[2] & 0x7f) << 14); 2407| 119k| if (len > 3) { ------------------ | Branch (2407:8): [True: 68.5k, False: 51.0k] ------------------ 2408| 68.5k| rv |= ((uint32_t) (data[3] & 0x7f) << 21); 2409| 68.5k| if (len > 4) ------------------ | Branch (2409:9): [True: 20.7k, False: 47.8k] ------------------ 2410| 20.7k| rv |= ((uint32_t) (data[4]) << 28); 2411| 68.5k| } 2412| 119k| } 2413| 316k| } 2414| 12.1M| return rv; 2415| 12.1M|} protobuf-c.c:unzigzag32: 2425| 1.20M|{ 2426| | // Note: Using unsigned types prevents undefined behavior 2427| 1.20M| return (int32_t)((v >> 1) ^ -(v & 1)); 2428| 1.20M|} protobuf-c.c:parse_fixed_uint32: 2432| 2.10k|{ 2433| 2.10k|#if !defined(WORDS_BIGENDIAN) 2434| 2.10k| uint32_t t; 2435| 2.10k| memcpy(&t, data, 4); 2436| 2.10k| return t; 2437| |#else 2438| | return data[0] | 2439| | ((uint32_t) (data[1]) << 8) | 2440| | ((uint32_t) (data[2]) << 16) | 2441| | ((uint32_t) (data[3]) << 24); 2442| |#endif 2443| 2.10k|} protobuf-c.c:parse_uint64: 2447| 4.75M|{ 2448| 4.75M| unsigned shift, i; 2449| 4.75M| uint64_t rv; 2450| | 2451| 4.75M| if (len < 5) ------------------ | Branch (2451:6): [True: 4.74M, False: 9.09k] ------------------ 2452| 4.74M| return parse_uint32(len, data); 2453| 9.09k| rv = ((uint64_t) (data[0] & 0x7f)) | 2454| 9.09k| ((uint64_t) (data[1] & 0x7f) << 7) | 2455| 9.09k| ((uint64_t) (data[2] & 0x7f) << 14) | 2456| 9.09k| ((uint64_t) (data[3] & 0x7f) << 21); 2457| 9.09k| shift = 28; 2458| 37.7k| for (i = 4; i < len; i++) { ------------------ | Branch (2458:14): [True: 28.6k, False: 9.09k] ------------------ 2459| 28.6k| rv |= (((uint64_t) (data[i] & 0x7f)) << shift); 2460| 28.6k| shift += 7; 2461| 28.6k| } 2462| 9.09k| return rv; 2463| 4.75M|} protobuf-c.c:unzigzag64: 2467| 1.43M|{ 2468| | // Note: Using unsigned types prevents undefined behavior 2469| 1.43M| return (int64_t)((v >> 1) ^ -(v & 1)); 2470| 1.43M|} protobuf-c.c:parse_fixed_uint64: 2474| 5.44k|{ 2475| 5.44k|#if !defined(WORDS_BIGENDIAN) 2476| 5.44k| uint64_t t; 2477| 5.44k| memcpy(&t, data, 8); 2478| 5.44k| return t; 2479| |#else 2480| | return (uint64_t) parse_fixed_uint32(data) | 2481| | (((uint64_t) parse_fixed_uint32(data + 4)) << 32); 2482| |#endif 2483| 5.44k|} protobuf-c.c:parse_boolean: 2487| 319k|{ 2488| 319k| unsigned i; 2489| 329k| for (i = 0; i < len; i++) ------------------ | Branch (2489:14): [True: 321k, False: 8.44k] ------------------ 2490| 321k| if (data[i] & 0x7f) ------------------ | Branch (2490:7): [True: 311k, False: 10.2k] ------------------ 2491| 311k| return TRUE; ------------------ | | 53| 311k|#define TRUE 1 ------------------ 2492| 8.44k| return FALSE; ------------------ | | 54| 8.44k|#define FALSE 0 ------------------ 2493| 319k|} protobuf-c.c:merge_messages: 2177| 16.4k|{ 2178| 16.4k| unsigned i; 2179| 16.4k| const ProtobufCFieldDescriptor *fields = 2180| 16.4k| latter_msg->descriptor->fields; 2181| 98.5k| for (i = 0; i < latter_msg->descriptor->n_fields; i++) { ------------------ | Branch (2181:14): [True: 82.1k, False: 16.4k] ------------------ 2182| 82.1k| if (fields[i].label == PROTOBUF_C_LABEL_REPEATED) { ------------------ | Branch (2182:7): [True: 16.4k, False: 65.6k] ------------------ 2183| 16.4k| size_t *n_earlier = 2184| 16.4k| STRUCT_MEMBER_PTR(size_t, earlier_msg, ------------------ | | 116| 16.4k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 16.4k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2185| 16.4k| fields[i].quantifier_offset); 2186| 16.4k| uint8_t **p_earlier = 2187| 16.4k| STRUCT_MEMBER_PTR(uint8_t *, earlier_msg, ------------------ | | 116| 16.4k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 16.4k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2188| 16.4k| fields[i].offset); 2189| 16.4k| size_t *n_latter = 2190| 16.4k| STRUCT_MEMBER_PTR(size_t, latter_msg, ------------------ | | 116| 16.4k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 16.4k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2191| 16.4k| fields[i].quantifier_offset); 2192| 16.4k| uint8_t **p_latter = 2193| 16.4k| STRUCT_MEMBER_PTR(uint8_t *, latter_msg, ------------------ | | 116| 16.4k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 16.4k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2194| 16.4k| fields[i].offset); 2195| | 2196| 16.4k| if (*n_earlier > 0) { ------------------ | Branch (2196:8): [True: 3.02k, False: 13.3k] ------------------ 2197| 3.02k| if (*n_latter > 0) { ------------------ | Branch (2197:9): [True: 1.48k, False: 1.54k] ------------------ 2198| | /* Concatenate the repeated field */ 2199| 1.48k| size_t el_size = 2200| 1.48k| sizeof_elt_in_repeated_array(fields[i].type); 2201| 1.48k| uint8_t *new_field; 2202| | 2203| 1.48k| new_field = do_alloc(allocator, 2204| 1.48k| (*n_earlier + *n_latter) * el_size); 2205| 1.48k| if (!new_field) ------------------ | Branch (2205:10): [True: 0, False: 1.48k] ------------------ 2206| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2207| | 2208| 1.48k| memcpy(new_field, *p_earlier, 2209| 1.48k| *n_earlier * el_size); 2210| 1.48k| memcpy(new_field + 2211| 1.48k| *n_earlier * el_size, 2212| 1.48k| *p_latter, 2213| 1.48k| *n_latter * el_size); 2214| | 2215| 1.48k| do_free(allocator, *p_latter); 2216| 1.48k| do_free(allocator, *p_earlier); 2217| 1.48k| *p_latter = new_field; 2218| 1.48k| *n_latter = *n_earlier + *n_latter; 2219| 1.54k| } else { 2220| | /* Zero copy the repeated field from the earlier message */ 2221| 1.54k| *n_latter = *n_earlier; 2222| 1.54k| *p_latter = *p_earlier; 2223| 1.54k| } 2224| | /* Make sure the field does not get double freed */ 2225| 3.02k| *n_earlier = 0; 2226| 3.02k| *p_earlier = 0; 2227| 3.02k| } 2228| 65.6k| } else if (fields[i].label == PROTOBUF_C_LABEL_OPTIONAL || ------------------ | Branch (2228:14): [True: 65.6k, False: 0] ------------------ 2229| 65.6k| fields[i].label == PROTOBUF_C_LABEL_NONE) { ------------------ | Branch (2229:7): [True: 0, False: 0] ------------------ 2230| 65.6k| const ProtobufCFieldDescriptor *field; 2231| 65.6k| uint32_t *earlier_case_p = STRUCT_MEMBER_PTR(uint32_t, ------------------ | | 116| 65.6k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 65.6k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2232| 65.6k| earlier_msg, 2233| 65.6k| fields[i]. 2234| 65.6k| quantifier_offset); 2235| 65.6k| uint32_t *latter_case_p = STRUCT_MEMBER_PTR(uint32_t, ------------------ | | 116| 65.6k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 65.6k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2236| 65.6k| latter_msg, 2237| 65.6k| fields[i]. 2238| 65.6k| quantifier_offset); 2239| 65.6k| protobuf_c_boolean need_to_merge = FALSE; ------------------ | | 54| 65.6k|#define FALSE 0 ------------------ 2240| 65.6k| void *earlier_elem; 2241| 65.6k| void *latter_elem; 2242| 65.6k| const void *def_val; 2243| | 2244| 65.6k| if (fields[i].flags & PROTOBUF_C_FIELD_FLAG_ONEOF) { ------------------ | Branch (2244:8): [True: 0, False: 65.6k] ------------------ 2245| 0| if (*latter_case_p == 0) { ------------------ | Branch (2245:9): [True: 0, False: 0] ------------------ 2246| | /* lookup correct oneof field */ 2247| 0| int field_index = 2248| 0| int_range_lookup( 2249| 0| latter_msg->descriptor 2250| 0| ->n_field_ranges, 2251| 0| latter_msg->descriptor 2252| 0| ->field_ranges, 2253| 0| *earlier_case_p); 2254| 0| if (field_index < 0) ------------------ | Branch (2254:10): [True: 0, False: 0] ------------------ 2255| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2256| 0| field = latter_msg->descriptor->fields + 2257| 0| field_index; 2258| 0| } else { 2259| | /* Oneof is present in the latter message, move on */ 2260| 0| continue; 2261| 0| } 2262| 65.6k| } else { 2263| 65.6k| field = &fields[i]; 2264| 65.6k| } 2265| | 2266| 65.6k| earlier_elem = STRUCT_MEMBER_P(earlier_msg, field->offset); ------------------ | | 98| 65.6k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) ------------------ 2267| 65.6k| latter_elem = STRUCT_MEMBER_P(latter_msg, field->offset); ------------------ | | 98| 65.6k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) ------------------ 2268| 65.6k| def_val = field->default_value; 2269| | 2270| 65.6k| switch (field->type) { 2271| 0| case PROTOBUF_C_TYPE_MESSAGE: { ------------------ | Branch (2271:4): [True: 0, False: 65.6k] ------------------ 2272| 0| ProtobufCMessage *em = *(ProtobufCMessage **) earlier_elem; 2273| 0| ProtobufCMessage *lm = *(ProtobufCMessage **) latter_elem; 2274| 0| if (em != NULL) { ------------------ | Branch (2274:9): [True: 0, False: 0] ------------------ 2275| 0| if (lm != NULL) { ------------------ | Branch (2275:10): [True: 0, False: 0] ------------------ 2276| 0| if (!merge_messages(em, lm, allocator)) ------------------ | Branch (2276:11): [True: 0, False: 0] ------------------ 2277| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2278| | /* Already merged */ 2279| 0| need_to_merge = FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2280| 0| } else { 2281| | /* Zero copy the message */ 2282| 0| need_to_merge = TRUE; ------------------ | | 53| 0|#define TRUE 1 ------------------ 2283| 0| } 2284| 0| } 2285| 0| break; 2286| 0| } 2287| 32.8k| case PROTOBUF_C_TYPE_BYTES: { ------------------ | Branch (2287:4): [True: 32.8k, False: 32.8k] ------------------ 2288| 32.8k| uint8_t *e_data = 2289| 32.8k| ((ProtobufCBinaryData *) earlier_elem)->data; 2290| 32.8k| uint8_t *l_data = 2291| 32.8k| ((ProtobufCBinaryData *) latter_elem)->data; 2292| 32.8k| const ProtobufCBinaryData *d_bd = 2293| 32.8k| (ProtobufCBinaryData *) def_val; 2294| | 2295| 32.8k| need_to_merge = 2296| 32.8k| (e_data != NULL && ------------------ | Branch (2296:7): [True: 31.7k, False: 1.05k] ------------------ 2297| 31.7k| (d_bd == NULL || ------------------ | Branch (2297:8): [True: 0, False: 31.7k] ------------------ 2298| 31.7k| e_data != d_bd->data)) && ------------------ | Branch (2298:8): [True: 2.69k, False: 29.0k] ------------------ 2299| 2.69k| (l_data == NULL || ------------------ | Branch (2299:7): [True: 540, False: 2.15k] ------------------ 2300| 2.15k| (d_bd != NULL && ------------------ | Branch (2300:8): [True: 2.15k, False: 0] ------------------ 2301| 2.15k| l_data == d_bd->data)); ------------------ | Branch (2301:8): [True: 1.70k, False: 449] ------------------ 2302| 32.8k| break; 2303| 0| } 2304| 16.4k| case PROTOBUF_C_TYPE_STRING: { ------------------ | Branch (2304:4): [True: 16.4k, False: 49.2k] ------------------ 2305| 16.4k| char *e_str = *(char **) earlier_elem; 2306| 16.4k| char *l_str = *(char **) latter_elem; 2307| 16.4k| const char *d_str = def_val; 2308| | 2309| 16.4k| need_to_merge = e_str != d_str && l_str == d_str; ------------------ | Branch (2309:21): [True: 1.70k, False: 14.7k] | Branch (2309:39): [True: 1.07k, False: 633] ------------------ 2310| 16.4k| break; 2311| 0| } 2312| 16.4k| default: { ------------------ | Branch (2312:4): [True: 16.4k, False: 49.2k] ------------------ 2313| | /* Could be has field or case enum, the logic is 2314| | * equivalent, since 0 (FALSE) means not set for 2315| | * oneof */ 2316| 16.4k| need_to_merge = (*earlier_case_p != 0) && ------------------ | Branch (2316:21): [True: 975, False: 15.4k] ------------------ 2317| 975| (*latter_case_p == 0); ------------------ | Branch (2317:7): [True: 847, False: 128] ------------------ 2318| 16.4k| break; 2319| 0| } 2320| 65.6k| } 2321| | 2322| 65.6k| if (need_to_merge) { ------------------ | Branch (2322:8): [True: 4.16k, False: 61.5k] ------------------ 2323| 4.16k| size_t el_size = 2324| 4.16k| sizeof_elt_in_repeated_array(field->type); 2325| 4.16k| memcpy(latter_elem, earlier_elem, el_size); 2326| | /* 2327| | * Reset the element from the old message to 0 2328| | * to make sure earlier message deallocation 2329| | * doesn't corrupt zero-copied data in the new 2330| | * message, earlier message will be freed after 2331| | * this function is called anyway 2332| | */ 2333| 4.16k| memset(earlier_elem, 0, el_size); 2334| | 2335| 4.16k| if (field->quantifier_offset != 0) { ------------------ | Branch (2335:9): [True: 3.09k, False: 1.07k] ------------------ 2336| | /* Set the has field or the case enum, 2337| | * if applicable */ 2338| 3.09k| *latter_case_p = *earlier_case_p; 2339| 3.09k| *earlier_case_p = 0; 2340| 3.09k| } 2341| 4.16k| } 2342| 65.6k| } 2343| 82.1k| } 2344| 16.4k| return TRUE; ------------------ | | 53| 16.4k|#define TRUE 1 ------------------ 2345| 16.4k|} protobuf-c.c:parse_optional_member: 2699| 29.7k|{ 2700| 29.7k| if (!parse_required_member(scanned_member, member, allocator, TRUE)) ------------------ | | 53| 29.7k|#define TRUE 1 ------------------ | Branch (2700:6): [True: 53, False: 29.6k] ------------------ 2701| 53| return FALSE; ------------------ | | 54| 53|#define FALSE 0 ------------------ 2702| 29.6k| if (scanned_member->field->quantifier_offset != 0) ------------------ | Branch (2702:6): [True: 9.81k, False: 19.8k] ------------------ 2703| 9.81k| STRUCT_MEMBER(protobuf_c_boolean, ------------------ | | 107| 9.81k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 9.81k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2704| 9.81k| message, 2705| 9.81k| scanned_member->field->quantifier_offset) = TRUE; ------------------ | | 53| 9.81k|#define TRUE 1 ------------------ 2706| 29.6k| return TRUE; ------------------ | | 53| 29.6k|#define TRUE 1 ------------------ 2707| 29.7k|} protobuf-c.c:parse_packed_repeated_member: 2747| 40.9k|{ 2748| 40.9k| const ProtobufCFieldDescriptor *field = scanned_member->field; 2749| 40.9k| size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset); ------------------ | | 116| 40.9k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 40.9k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2750| 40.9k| size_t siz = sizeof_elt_in_repeated_array(field->type); 2751| 40.9k| void *array = *(char **) member + siz * (*p_n); 2752| 40.9k| const uint8_t *at = scanned_member->data + scanned_member->length_prefix_len; 2753| 40.9k| size_t rem = scanned_member->len - scanned_member->length_prefix_len; 2754| 40.9k| size_t count = 0; 2755| |#if defined(WORDS_BIGENDIAN) 2756| | unsigned i; 2757| |#endif 2758| | 2759| 40.9k| switch (field->type) { 2760| 4.89k| case PROTOBUF_C_TYPE_SFIXED32: ------------------ | Branch (2760:2): [True: 4.89k, False: 36.0k] ------------------ 2761| 6.57k| case PROTOBUF_C_TYPE_FIXED32: ------------------ | Branch (2761:2): [True: 1.67k, False: 39.2k] ------------------ 2762| 12.1k| case PROTOBUF_C_TYPE_FLOAT: ------------------ | Branch (2762:2): [True: 5.57k, False: 35.3k] ------------------ 2763| 12.1k| count = (scanned_member->len - scanned_member->length_prefix_len) / 4; 2764| 12.1k|#if !defined(WORDS_BIGENDIAN) 2765| 12.1k| goto no_unpacking_needed; 2766| |#else 2767| | for (i = 0; i < count; i++) { 2768| | ((uint32_t *) array)[i] = parse_fixed_uint32(at); 2769| | at += 4; 2770| | } 2771| | break; 2772| |#endif 2773| 536| case PROTOBUF_C_TYPE_SFIXED64: ------------------ | Branch (2773:2): [True: 536, False: 40.3k] ------------------ 2774| 1.16k| case PROTOBUF_C_TYPE_FIXED64: ------------------ | Branch (2774:2): [True: 629, False: 40.2k] ------------------ 2775| 2.42k| case PROTOBUF_C_TYPE_DOUBLE: ------------------ | Branch (2775:2): [True: 1.26k, False: 39.6k] ------------------ 2776| 2.42k| count = (scanned_member->len - scanned_member->length_prefix_len) / 8; 2777| 2.42k|#if !defined(WORDS_BIGENDIAN) 2778| 2.42k| goto no_unpacking_needed; 2779| |#else 2780| | for (i = 0; i < count; i++) { 2781| | ((uint64_t *) array)[i] = parse_fixed_uint64(at); 2782| | at += 8; 2783| | } 2784| | break; 2785| |#endif 2786| 1.14k| case PROTOBUF_C_TYPE_ENUM: ------------------ | Branch (2786:2): [True: 1.14k, False: 39.7k] ------------------ 2787| 4.58k| case PROTOBUF_C_TYPE_INT32: ------------------ | Branch (2787:2): [True: 3.44k, False: 37.4k] ------------------ 2788| 2.38M| while (rem > 0) { ------------------ | Branch (2788:10): [True: 2.38M, False: 4.56k] ------------------ 2789| 2.38M| unsigned s = scan_varint(rem, at); 2790| 2.38M| if (s == 0) { ------------------ | Branch (2790:8): [True: 16, False: 2.38M] ------------------ 2791| 16| PROTOBUF_C_UNPACK_ERROR("bad packed-repeated int32 value"); 2792| 16| return FALSE; ------------------ | | 54| 16|#define FALSE 0 ------------------ 2793| 16| } 2794| 2.38M| ((int32_t *) array)[count++] = parse_int32(s, at); 2795| 2.38M| at += s; 2796| 2.38M| rem -= s; 2797| 2.38M| } 2798| 4.56k| break; 2799| 4.56k| case PROTOBUF_C_TYPE_SINT32: ------------------ | Branch (2799:2): [True: 3.43k, False: 37.4k] ------------------ 2800| 960k| while (rem > 0) { ------------------ | Branch (2800:10): [True: 957k, False: 3.41k] ------------------ 2801| 957k| unsigned s = scan_varint(rem, at); 2802| 957k| if (s == 0) { ------------------ | Branch (2802:8): [True: 27, False: 957k] ------------------ 2803| 27| PROTOBUF_C_UNPACK_ERROR("bad packed-repeated sint32 value"); 2804| 27| return FALSE; ------------------ | | 54| 27|#define FALSE 0 ------------------ 2805| 27| } 2806| 957k| ((int32_t *) array)[count++] = unzigzag32(parse_uint32(s, at)); 2807| 957k| at += s; 2808| 957k| rem -= s; 2809| 957k| } 2810| 3.41k| break; 2811| 3.41k| case PROTOBUF_C_TYPE_UINT32: ------------------ | Branch (2811:2): [True: 2.01k, False: 38.8k] ------------------ 2812| 2.63M| while (rem > 0) { ------------------ | Branch (2812:10): [True: 2.63M, False: 1.98k] ------------------ 2813| 2.63M| unsigned s = scan_varint(rem, at); 2814| 2.63M| if (s == 0) { ------------------ | Branch (2814:8): [True: 27, False: 2.63M] ------------------ 2815| 27| PROTOBUF_C_UNPACK_ERROR("bad packed-repeated enum or uint32 value"); 2816| 27| return FALSE; ------------------ | | 54| 27|#define FALSE 0 ------------------ 2817| 27| } 2818| 2.63M| ((uint32_t *) array)[count++] = parse_uint32(s, at); 2819| 2.63M| at += s; 2820| 2.63M| rem -= s; 2821| 2.63M| } 2822| 1.98k| break; 2823| | 2824| 7.05k| case PROTOBUF_C_TYPE_SINT64: ------------------ | Branch (2824:2): [True: 7.05k, False: 33.8k] ------------------ 2825| 1.43M| while (rem > 0) { ------------------ | Branch (2825:10): [True: 1.42M, False: 7.02k] ------------------ 2826| 1.42M| unsigned s = scan_varint(rem, at); 2827| 1.42M| if (s == 0) { ------------------ | Branch (2827:8): [True: 30, False: 1.42M] ------------------ 2828| 30| PROTOBUF_C_UNPACK_ERROR("bad packed-repeated sint64 value"); 2829| 30| return FALSE; ------------------ | | 54| 30|#define FALSE 0 ------------------ 2830| 30| } 2831| 1.42M| ((int64_t *) array)[count++] = unzigzag64(parse_uint64(s, at)); 2832| 1.42M| at += s; 2833| 1.42M| rem -= s; 2834| 1.42M| } 2835| 7.02k| break; 2836| 7.02k| case PROTOBUF_C_TYPE_INT64: ------------------ | Branch (2836:2): [True: 995, False: 39.9k] ------------------ 2837| 5.99k| case PROTOBUF_C_TYPE_UINT64: ------------------ | Branch (2837:2): [True: 4.99k, False: 35.9k] ------------------ 2838| 1.55M| while (rem > 0) { ------------------ | Branch (2838:10): [True: 1.54M, False: 5.97k] ------------------ 2839| 1.54M| unsigned s = scan_varint(rem, at); 2840| 1.54M| if (s == 0) { ------------------ | Branch (2840:8): [True: 21, False: 1.54M] ------------------ 2841| 21| PROTOBUF_C_UNPACK_ERROR("bad packed-repeated int64/uint64 value"); 2842| 21| return FALSE; ------------------ | | 54| 21|#define FALSE 0 ------------------ 2843| 21| } 2844| 1.54M| ((int64_t *) array)[count++] = parse_uint64(s, at); 2845| 1.54M| at += s; 2846| 1.54M| rem -= s; 2847| 1.54M| } 2848| 5.97k| break; 2849| 5.97k| case PROTOBUF_C_TYPE_BOOL: ------------------ | Branch (2849:2): [True: 3.25k, False: 37.6k] ------------------ 2850| 289k| while (rem > 0) { ------------------ | Branch (2850:10): [True: 286k, False: 3.23k] ------------------ 2851| 286k| unsigned s = scan_varint(rem, at); 2852| 286k| if (s == 0) { ------------------ | Branch (2852:8): [True: 22, False: 286k] ------------------ 2853| 22| PROTOBUF_C_UNPACK_ERROR("bad packed-repeated boolean value"); 2854| 22| return FALSE; ------------------ | | 54| 22|#define FALSE 0 ------------------ 2855| 22| } 2856| 286k| ((protobuf_c_boolean *) array)[count++] = parse_boolean(s, at); 2857| 286k| at += s; 2858| 286k| rem -= s; 2859| 286k| } 2860| 3.23k| break; 2861| 3.23k| default: ------------------ | Branch (2861:2): [True: 0, False: 40.9k] ------------------ 2862| 0| PROTOBUF_C__ASSERT_NOT_REACHED(); ------------------ | | 56| 0|#define PROTOBUF_C__ASSERT_NOT_REACHED() assert(0) ------------------ | Branch (2862:3): [Folded, False: 0] | Branch (2862:3): [Folded, False: 0] ------------------ 2863| 40.9k| } 2864| 26.1k| *p_n += count; 2865| 26.1k| return TRUE; ------------------ | | 53| 26.1k|#define TRUE 1 ------------------ 2866| | 2867| 0|#if !defined(WORDS_BIGENDIAN) 2868| 14.5k|no_unpacking_needed: 2869| 14.5k| memcpy(array, at, count * siz); 2870| 14.5k| *p_n += count; 2871| 14.5k| return TRUE; ------------------ | | 53| 14.5k|#define TRUE 1 ------------------ 2872| 40.9k|#endif 2873| 40.9k|} protobuf-c.c:scan_varint: 2731| 9.23M|{ 2732| 9.23M| unsigned i; 2733| 9.23M| if (len > 10) ------------------ | Branch (2733:6): [True: 9.11M, False: 115k] ------------------ 2734| 9.11M| len = 10; 2735| 9.73M| for (i = 0; i < len; i++) ------------------ | Branch (2735:14): [True: 9.73M, False: 143] ------------------ 2736| 9.73M| if ((data[i] & 0x80) == 0) ------------------ | Branch (2736:7): [True: 9.23M, False: 499k] ------------------ 2737| 9.23M| break; 2738| 9.23M| if (i == len) ------------------ | Branch (2738:6): [True: 143, False: 9.23M] ------------------ 2739| 143| return 0; 2740| 9.23M| return i + 1; 2741| 9.23M|} protobuf-c.c:parse_repeated_member: 2714| 3.00M|{ 2715| 3.00M| const ProtobufCFieldDescriptor *field = scanned_member->field; 2716| 3.00M| size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset); ------------------ | | 116| 3.00M| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 3.00M| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2717| 3.00M| size_t siz = sizeof_elt_in_repeated_array(field->type); 2718| 3.00M| char *array = *(char **) member; 2719| | 2720| 3.00M| if (!parse_required_member(scanned_member, array + siz * (*p_n), ------------------ | Branch (2720:6): [True: 299, False: 3.00M] ------------------ 2721| 3.00M| allocator, FALSE)) ------------------ | | 54| 3.00M|#define FALSE 0 ------------------ 2722| 299| { 2723| 299| return FALSE; ------------------ | | 54| 299|#define FALSE 0 ------------------ 2724| 299| } 2725| 3.00M| *p_n += 1; 2726| 3.00M| return TRUE; ------------------ | | 53| 3.00M|#define TRUE 1 ------------------ 2727| 3.00M|} foo__sub_mess__sub_sub_mess__init: 12| 18.3k|{ 13| | static const Foo__SubMess__SubSubMess init_value = FOO__SUB_MESS__SUB_SUB_MESS__INIT; ------------------ | | 126| 18.3k| { PROTOBUF_C_MESSAGE_INIT (&foo__sub_mess__sub_sub_mess__descriptor) \ | | ------------------ | | | | 1000| 18.3k|#define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL } | | ------------------ | | 127| 18.3k| , 0, 100, 0,NULL, 0, { 8, foo__sub_mess__sub_sub_mess__bytes1__default_value_data }, foo__sub_mess__sub_sub_mess__str1__default_value, 0, { 12, foo__sub_mess__sub_sub_mess__str2__default_value_data } } ------------------ 14| 18.3k| *message = init_value; 15| 18.3k|} foo__sub_mess__init: 18| 70.1k|{ 19| | static const Foo__SubMess init_value = FOO__SUB_MESS__INIT; ------------------ | | 144| 70.1k| { PROTOBUF_C_MESSAGE_INIT (&foo__sub_mess__descriptor) \ | | ------------------ | | | | 1000| 70.1k|#define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL } | | ------------------ | | 145| 70.1k| , 0, 0, 0, 0, 0, 0,NULL, NULL, NULL } ------------------ 20| 70.1k| *message = init_value; 21| 70.1k|} foo__test_mess__init: 423| 2.04k|{ 424| | static const Foo__TestMess init_value = FOO__TEST_MESS__INIT; ------------------ | | 269| 2.04k| { PROTOBUF_C_MESSAGE_INIT (&foo__test_mess__descriptor) \ | | ------------------ | | | | 1000| 2.04k|#define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL } | | ------------------ | | 270| 2.04k| , 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL } ------------------ 425| 2.04k| *message = init_value; 426| 2.04k|} LLVMFuzzerTestOneInput: 23| 2.04k|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 24| | /* 25| | * Test the core protobuf-c parsing by unpacking as TestMess. 26| | * This message type contains repeated fields of all types including 27| | * nested messages, which exercises all parsing code paths in 28| | * protobuf_c_message_unpack(). 29| | */ 30| 2.04k| ProtobufCMessage *msg = protobuf_c_message_unpack( 31| 2.04k| &foo__test_mess__descriptor, NULL, size, data); 32| 2.04k| if (msg != NULL) { ------------------ | Branch (32:9): [True: 1.26k, False: 782] ------------------ 33| 1.26k| protobuf_c_message_free_unpacked(msg, NULL); 34| 1.26k| } 35| | 36| 2.04k| return 0; 37| 2.04k|}