protobuf_c_message_unpack: 3031| 95.8k|{ 3032| 95.8k| ProtobufCMessage *rv; 3033| 95.8k| size_t rem = len; 3034| 95.8k| const uint8_t *at = data; 3035| 95.8k| const ProtobufCFieldDescriptor *last_field = desc->fields + 0; 3036| 95.8k| ScannedMember first_member_slab[1UL << 3037| 95.8k| 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| 95.8k| ScannedMember *scanned_member_slabs[MAX_SCANNED_MEMBER_SLAB + 1]; 3046| 95.8k| unsigned which_slab = 0; /* the slab we are currently populating */ 3047| 95.8k| unsigned in_slab_index = 0; /* number of members in the slab */ 3048| 95.8k| size_t n_unknown = 0; 3049| 95.8k| unsigned f; 3050| 95.8k| unsigned j; 3051| 95.8k| unsigned i_slab; 3052| 95.8k| unsigned last_field_index = 0; 3053| 95.8k| unsigned required_fields_bitmap_len; 3054| 95.8k| unsigned char required_fields_bitmap_stack[16]; 3055| 95.8k| unsigned char *required_fields_bitmap = required_fields_bitmap_stack; 3056| 95.8k| protobuf_c_boolean required_fields_bitmap_alloced = FALSE; ------------------ | | 54| 95.8k|#define FALSE 0 ------------------ 3057| | 3058| 95.8k| ASSERT_IS_MESSAGE_DESCRIPTOR(desc); ------------------ | | 124| 95.8k| assert((desc)->magic == PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC) ------------------ | Branch (3058:2): [True: 0, False: 95.8k] | Branch (3058:2): [True: 95.8k, False: 0] ------------------ 3059| | 3060| 95.8k| if (allocator == NULL) ------------------ | Branch (3060:6): [True: 2.09k, False: 93.7k] ------------------ 3061| 2.09k| allocator = &protobuf_c__allocator; 3062| | 3063| 95.8k| rv = do_alloc(allocator, desc->sizeof_message); 3064| 95.8k| if (!rv) ------------------ | Branch (3064:6): [True: 0, False: 95.8k] ------------------ 3065| 0| return (NULL); 3066| 95.8k| scanned_member_slabs[0] = first_member_slab; 3067| | 3068| 95.8k| required_fields_bitmap_len = (desc->n_fields + 7) / 8; 3069| 95.8k| if (required_fields_bitmap_len > sizeof(required_fields_bitmap_stack)) { ------------------ | Branch (3069:6): [True: 0, False: 95.8k] ------------------ 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| 95.8k| 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| 95.8k| if (desc->message_init != NULL) ------------------ | Branch (3085:6): [True: 95.8k, False: 0] ------------------ 3086| 95.8k| protobuf_c_message_init(desc, rv); 3087| 0| else 3088| 0| message_init_generic(desc, rv); 3089| | 3090| 7.72M| while (rem > 0) { ------------------ | Branch (3090:9): [True: 7.63M, False: 95.3k] ------------------ 3091| 7.63M| uint32_t tag; 3092| 7.63M| uint8_t wire_type; 3093| 7.63M| size_t used = parse_tag_and_wiretype(rem, at, &tag, &wire_type); 3094| 7.63M| const ProtobufCFieldDescriptor *field; 3095| 7.63M| ScannedMember tmp; 3096| | 3097| 7.63M| if (used == 0) { ------------------ | Branch (3097:7): [True: 67, False: 7.63M] ------------------ 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| 7.63M| if (last_field == NULL || last_field->id != tag) { ------------------ | Branch (3106:7): [True: 0, False: 7.63M] | Branch (3106:29): [True: 838k, False: 6.79M] ------------------ 3107| | /* lookup field */ 3108| 838k| int field_index = 3109| 838k| int_range_lookup(desc->n_field_ranges, 3110| 838k| desc->field_ranges, 3111| 838k| tag); 3112| 838k| if (field_index < 0) { ------------------ | Branch (3112:8): [True: 626k, False: 211k] ------------------ 3113| 626k| field = NULL; 3114| 626k| n_unknown++; 3115| 626k| } else { 3116| 211k| field = desc->fields + field_index; 3117| 211k| last_field = field; 3118| 211k| last_field_index = field_index; 3119| 211k| } 3120| 6.79M| } else { 3121| 6.79M| field = last_field; 3122| 6.79M| } 3123| | 3124| 7.63M| if (field != NULL && field->label == PROTOBUF_C_LABEL_REQUIRED) ------------------ | Branch (3124:7): [True: 7.00M, False: 626k] | Branch (3124:24): [True: 1.03M, False: 5.97M] ------------------ 3125| 1.03M| REQUIRED_FIELD_BITMAP_SET(last_field_index); ------------------ | | 3022| 1.03M| (required_fields_bitmap[(index)/8] |= (1UL<<((index)%8))) ------------------ 3126| | 3127| 7.63M| at += used; 3128| 7.63M| rem -= used; 3129| 7.63M| tmp.tag = tag; 3130| 7.63M| tmp.wire_type = wire_type; 3131| 7.63M| tmp.field = field; 3132| 7.63M| tmp.data = at; 3133| 7.63M| tmp.length_prefix_len = 0; 3134| | 3135| 7.63M| switch (wire_type) { 3136| 6.88M| case PROTOBUF_C_WIRE_TYPE_VARINT: { ------------------ | Branch (3136:3): [True: 6.88M, False: 743k] ------------------ 3137| 6.88M| unsigned max_len = rem < 10 ? rem : 10; ------------------ | Branch (3137:23): [True: 87.0k, False: 6.80M] ------------------ 3138| 6.88M| unsigned i; 3139| | 3140| 7.26M| for (i = 0; i < max_len; i++) ------------------ | Branch (3140:16): [True: 7.26M, False: 82] ------------------ 3141| 7.26M| if ((at[i] & 0x80) == 0) ------------------ | Branch (3141:9): [True: 6.88M, False: 379k] ------------------ 3142| 6.88M| break; 3143| 6.88M| if (i == max_len) { ------------------ | Branch (3143:8): [True: 82, False: 6.88M] ------------------ 3144| 82| PROTOBUF_C_UNPACK_ERROR("unterminated varint at offset %u", 3145| 82| (unsigned) (at - data)); 3146| 82| goto error_cleanup_during_scan; 3147| 82| } 3148| 6.88M| tmp.len = i + 1; 3149| 6.88M| break; 3150| 6.88M| } 3151| 17.3k| case PROTOBUF_C_WIRE_TYPE_64BIT: ------------------ | Branch (3151:3): [True: 17.3k, False: 7.61M] ------------------ 3152| 17.3k| if (rem < 8) { ------------------ | Branch (3152:8): [True: 17, False: 17.3k] ------------------ 3153| 17| PROTOBUF_C_UNPACK_ERROR("too short after 64bit wiretype at offset %u", 3154| 17| (unsigned) (at - data)); 3155| 17| goto error_cleanup_during_scan; 3156| 17| } 3157| 17.3k| tmp.len = 8; 3158| 17.3k| break; 3159| 681k| case PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED: { ------------------ | Branch (3159:3): [True: 681k, False: 6.95M] ------------------ 3160| 681k| size_t pref_len; 3161| | 3162| 681k| tmp.len = scan_length_prefixed_data(rem, at, &pref_len); 3163| 681k| if (tmp.len == 0) { ------------------ | Branch (3163:8): [True: 168, False: 680k] ------------------ 3164| | /* NOTE: scan_length_prefixed_data calls UNPACK_ERROR */ 3165| 168| goto error_cleanup_during_scan; 3166| 168| } 3167| 680k| tmp.length_prefix_len = pref_len; 3168| 680k| break; 3169| 681k| } 3170| 44.6k| case PROTOBUF_C_WIRE_TYPE_32BIT: ------------------ | Branch (3170:3): [True: 44.6k, False: 7.58M] ------------------ 3171| 44.6k| if (rem < 4) { ------------------ | Branch (3171:8): [True: 19, False: 44.6k] ------------------ 3172| 19| PROTOBUF_C_UNPACK_ERROR("too short after 32bit wiretype at offset %u", 3173| 19| (unsigned) (at - data)); 3174| 19| goto error_cleanup_during_scan; 3175| 19| } 3176| 44.6k| tmp.len = 4; 3177| 44.6k| break; 3178| 137| default: ------------------ | Branch (3178:3): [True: 137, False: 7.63M] ------------------ 3179| 137| PROTOBUF_C_UNPACK_ERROR("unsupported tag %u at offset %u", 3180| 137| wire_type, (unsigned) (at - data)); 3181| 137| goto error_cleanup_during_scan; 3182| 7.63M| } 3183| | 3184| 7.63M| if (in_slab_index == (1UL << ------------------ | Branch (3184:7): [True: 4.91k, False: 7.62M] ------------------ 3185| 7.63M| (which_slab + FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2))) ------------------ | | 3010| 7.63M|#define FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2 4 ------------------ 3186| 4.91k| { 3187| 4.91k| size_t size; 3188| | 3189| 4.91k| in_slab_index = 0; 3190| 4.91k| if (which_slab == MAX_SCANNED_MEMBER_SLAB) { ------------------ | | 3017| 4.91k| (sizeof(unsigned int)*8 - 1 \ | | 3018| 4.91k| - BOUND_SIZEOF_SCANNED_MEMBER_LOG2 \ | | ------------------ | | | | 2097| 4.91k|#define BOUND_SIZEOF_SCANNED_MEMBER_LOG2 5 | | ------------------ | | 3019| 4.91k| - FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2) | | ------------------ | | | | 3010| 4.91k|#define FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2 4 | | ------------------ ------------------ | Branch (3190:8): [True: 0, False: 4.91k] ------------------ 3191| 0| PROTOBUF_C_UNPACK_ERROR("too many fields"); 3192| 0| goto error_cleanup_during_scan; 3193| 0| } 3194| 4.91k| which_slab++; 3195| 4.91k| size = sizeof(ScannedMember) 3196| 4.91k| << (which_slab + FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2); ------------------ | | 3010| 4.91k|#define FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2 4 ------------------ 3197| 4.91k| scanned_member_slabs[which_slab] = do_alloc(allocator, size); 3198| 4.91k| if (scanned_member_slabs[which_slab] == NULL) ------------------ | Branch (3198:8): [True: 0, False: 4.91k] ------------------ 3199| 0| goto error_cleanup_during_scan; 3200| 4.91k| } 3201| 7.63M| scanned_member_slabs[which_slab][in_slab_index++] = tmp; 3202| | 3203| 7.63M| if (field != NULL && field->label == PROTOBUF_C_LABEL_REPEATED) { ------------------ | Branch (3203:7): [True: 7.00M, False: 626k] | Branch (3203:24): [True: 5.94M, False: 1.06M] ------------------ 3204| 5.94M| size_t *n = STRUCT_MEMBER_PTR(size_t, rv, ------------------ | | 116| 5.94M| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 5.94M| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3205| 5.94M| field->quantifier_offset); 3206| 5.94M| if (wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED && ------------------ | Branch (3206:8): [True: 595k, False: 5.34M] ------------------ 3207| 595k| (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED) || ------------------ | Branch (3207:9): [True: 0, False: 595k] ------------------ 3208| 595k| is_packable_type(field->type))) ------------------ | Branch (3208:9): [True: 51.6k, False: 543k] ------------------ 3209| 51.6k| { 3210| 51.6k| size_t count; 3211| 51.6k| if (!count_packed_elements(field->type, ------------------ | Branch (3211:9): [True: 7, False: 51.5k] ------------------ 3212| 51.6k| tmp.len - 3213| 51.6k| tmp.length_prefix_len, 3214| 51.6k| tmp.data + 3215| 51.6k| tmp.length_prefix_len, 3216| 51.6k| &count)) 3217| 7| { 3218| 7| PROTOBUF_C_UNPACK_ERROR("counting packed elements"); 3219| 7| goto error_cleanup_during_scan; 3220| 7| } 3221| 51.5k| *n += count; 3222| 5.88M| } else { 3223| 5.88M| *n += 1; 3224| 5.88M| } 3225| 5.94M| } 3226| | 3227| 7.63M| at += tmp.len; 3228| 7.63M| rem -= tmp.len; 3229| 7.63M| } 3230| | 3231| | /* allocate space for repeated fields, also check that all required fields have been set */ 3232| 670k| for (f = 0; f < desc->n_fields; f++) { ------------------ | Branch (3232:14): [True: 574k, False: 95.2k] ------------------ 3233| 574k| const ProtobufCFieldDescriptor *field = desc->fields + f; 3234| 574k| if (field == NULL) { ------------------ | Branch (3234:7): [True: 0, False: 574k] ------------------ 3235| 0| continue; 3236| 0| } 3237| 574k| if (field->label == PROTOBUF_C_LABEL_REPEATED) { ------------------ | Branch (3237:7): [True: 124k, False: 450k] ------------------ 3238| 124k| size_t siz = 3239| 124k| sizeof_elt_in_repeated_array(field->type); 3240| 124k| size_t *n_ptr = 3241| 124k| STRUCT_MEMBER_PTR(size_t, rv, ------------------ | | 116| 124k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 124k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3242| 124k| field->quantifier_offset); 3243| 124k| if (*n_ptr != 0) { ------------------ | Branch (3243:8): [True: 4.40k, False: 120k] ------------------ 3244| 4.40k| unsigned n = *n_ptr; 3245| 4.40k| void *a; 3246| 4.40k| *n_ptr = 0; 3247| 4.40k| assert(rv->descriptor != NULL); ------------------ | Branch (3247:5): [True: 0, False: 4.40k] | Branch (3247:5): [True: 4.40k, False: 0] ------------------ 3248| 4.40k|#define CLEAR_REMAINING_N_PTRS() \ 3249| 4.40k| for(f++;f < desc->n_fields; f++) \ 3250| 4.40k| { \ 3251| 4.40k| field = desc->fields + f; \ 3252| 4.40k| if (field->label == PROTOBUF_C_LABEL_REPEATED) \ 3253| 4.40k| STRUCT_MEMBER (size_t, rv, field->quantifier_offset) = 0; \ 3254| 4.40k| } 3255| 4.40k| a = do_alloc(allocator, siz * n); 3256| 4.40k| if (!a) { ------------------ | Branch (3256:9): [True: 0, False: 4.40k] ------------------ 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.40k| STRUCT_MEMBER(void *, rv, field->offset) = a; ------------------ | | 107| 4.40k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 4.40k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3261| 4.40k| } 3262| 450k| } else if (field->label == PROTOBUF_C_LABEL_REQUIRED) { ------------------ | Branch (3262:14): [True: 76.0k, False: 374k] ------------------ 3263| 76.0k| if (field->default_value == NULL && ------------------ | Branch (3263:8): [True: 76.0k, False: 0] ------------------ 3264| 76.0k| !REQUIRED_FIELD_BITMAP_IS_SET(f)) ------------------ | | 3025| 76.0k| (required_fields_bitmap[(index)/8] & (1UL<<((index)%8))) ------------------ | Branch (3264:8): [True: 28, False: 76.0k] ------------------ 3265| 28| { 3266| 28| CLEAR_REMAINING_N_PTRS(); ------------------ | | 3249| 168| for(f++;f < desc->n_fields; f++) \ | | ------------------ | | | Branch (3249:23): [True: 140, False: 28] | | ------------------ | | 3250| 140| { \ | | 3251| 140| field = desc->fields + f; \ | | 3252| 140| if (field->label == PROTOBUF_C_LABEL_REPEATED) \ | | ------------------ | | | Branch (3252:23): [True: 28, False: 112] | | ------------------ | | 3253| 140| STRUCT_MEMBER (size_t, rv, field->quantifier_offset) = 0; \ | | ------------------ | | | | 107| 28| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | | | ------------------ | | | | | | 98| 28| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | | | ------------------ | | ------------------ | | 3254| 140| } ------------------ 3267| 28| PROTOBUF_C_UNPACK_ERROR("message '%s': missing required field '%s'", 3268| 28| desc->name, field->name); 3269| 28| goto error_cleanup; 3270| 28| } 3271| 76.0k| } 3272| 574k| } 3273| 95.2k|#undef CLEAR_REMAINING_N_PTRS 3274| | 3275| | /* allocate space for unknown fields */ 3276| 95.2k| if (n_unknown) { ------------------ | Branch (3276:6): [True: 3.45k, False: 91.8k] ------------------ 3277| 3.45k| rv->unknown_fields = do_alloc(allocator, 3278| 3.45k| n_unknown * sizeof(ProtobufCMessageUnknownField)); 3279| 3.45k| if (rv->unknown_fields == NULL) ------------------ | Branch (3279:7): [True: 0, False: 3.45k] ------------------ 3280| 0| goto error_cleanup; 3281| 91.8k| } else { 3282| 91.8k| rv->unknown_fields = NULL; 3283| 91.8k| } 3284| | 3285| | /* do real parsing */ 3286| 194k| for (i_slab = 0; i_slab <= which_slab; i_slab++) { ------------------ | Branch (3286:19): [True: 99.6k, False: 94.7k] ------------------ 3287| 99.6k| unsigned max = (i_slab == which_slab) ? ------------------ | Branch (3287:18): [True: 95.2k, False: 4.48k] ------------------ 3288| 95.2k| in_slab_index : (1UL << (i_slab + 4)); 3289| 99.6k| ScannedMember *slab = scanned_member_slabs[i_slab]; 3290| | 3291| 5.17M| for (j = 0; j < max; j++) { ------------------ | Branch (3291:15): [True: 5.07M, False: 99.1k] ------------------ 3292| 5.07M| if (!parse_member(slab + j, rv, allocator)) { ------------------ | Branch (3292:8): [True: 510, False: 5.07M] ------------------ 3293| 510| PROTOBUF_C_UNPACK_ERROR("error parsing member %s of %s", 3294| 510| slab->field ? slab->field->name : "*unknown-field*", 3295| 510| desc->name); 3296| 510| goto error_cleanup; 3297| 510| } 3298| 5.07M| } 3299| 99.6k| } 3300| | 3301| | /* cleanup */ 3302| 98.6k| for (j = 1; j <= which_slab; j++) ------------------ | Branch (3302:14): [True: 3.89k, False: 94.7k] ------------------ 3303| 3.89k| do_free(allocator, scanned_member_slabs[j]); 3304| 94.7k| if (required_fields_bitmap_alloced) ------------------ | Branch (3304:6): [True: 0, False: 94.7k] ------------------ 3305| 0| do_free(allocator, required_fields_bitmap); 3306| 94.7k| return rv; 3307| | 3308| 538|error_cleanup: 3309| 538| protobuf_c_message_free_unpacked(rv, allocator); 3310| 1.23k| for (j = 1; j <= which_slab; j++) ------------------ | Branch (3310:14): [True: 697, False: 538] ------------------ 3311| 697| do_free(allocator, scanned_member_slabs[j]); 3312| 538| if (required_fields_bitmap_alloced) ------------------ | Branch (3312:6): [True: 0, False: 538] ------------------ 3313| 0| do_free(allocator, required_fields_bitmap); 3314| 538| return NULL; 3315| | 3316| 497|error_cleanup_during_scan: 3317| 497| do_free(allocator, rv); 3318| 823| for (j = 1; j <= which_slab; j++) ------------------ | Branch (3318:14): [True: 326, False: 497] ------------------ 3319| 326| do_free(allocator, scanned_member_slabs[j]); 3320| 497| if (required_fields_bitmap_alloced) ------------------ | Branch (3320:6): [True: 0, False: 497] ------------------ 3321| 0| do_free(allocator, required_fields_bitmap); 3322| | return NULL; 3323| 95.2k|} protobuf_c_message_free_unpacked: 3328| 95.3k|{ 3329| 95.3k| const ProtobufCMessageDescriptor *desc; 3330| 95.3k| unsigned f; 3331| | 3332| 95.3k| if (message == NULL) ------------------ | Branch (3332:6): [True: 0, False: 95.3k] ------------------ 3333| 0| return; 3334| | 3335| 95.3k| desc = message->descriptor; 3336| | 3337| 95.3k| ASSERT_IS_MESSAGE(message); ------------------ | | 127| 95.3k| ASSERT_IS_MESSAGE_DESCRIPTOR((message)->descriptor) | | ------------------ | | | | 124| 95.3k| assert((desc)->magic == PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC) | | ------------------ ------------------ | Branch (3337:2): [True: 0, False: 95.3k] | Branch (3337:2): [True: 95.3k, False: 0] ------------------ 3338| | 3339| 95.3k| if (allocator == NULL) ------------------ | Branch (3339:6): [True: 1.28k, False: 94.0k] ------------------ 3340| 1.28k| allocator = &protobuf_c__allocator; 3341| 95.3k| message->descriptor = NULL; 3342| 670k| for (f = 0; f < desc->n_fields; f++) { ------------------ | Branch (3342:14): [True: 575k, False: 95.3k] ------------------ 3343| 575k| if (0 != (desc->fields[f].flags & PROTOBUF_C_FIELD_FLAG_ONEOF) && ------------------ | Branch (3343:7): [True: 0, False: 575k] ------------------ 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| 575k| if (desc->fields[f].label == PROTOBUF_C_LABEL_REPEATED) { ------------------ | Branch (3351:7): [True: 124k, False: 450k] ------------------ 3352| 124k| size_t n = STRUCT_MEMBER(size_t, ------------------ | | 107| 124k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 124k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3353| 124k| message, 3354| 124k| desc->fields[f].quantifier_offset); 3355| 124k| void *arr = STRUCT_MEMBER(void *, ------------------ | | 107| 124k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 124k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3356| 124k| message, 3357| 124k| desc->fields[f].offset); 3358| | 3359| 124k| if (arr != NULL) { ------------------ | Branch (3359:8): [True: 2.99k, False: 121k] ------------------ 3360| 2.99k| if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) { ------------------ | Branch (3360:9): [True: 51, False: 2.94k] ------------------ 3361| 51| unsigned i; 3362| 133k| for (i = 0; i < n; i++) ------------------ | Branch (3362:18): [True: 133k, False: 51] ------------------ 3363| 133k| do_free(allocator, ((char **) arr)[i]); 3364| 2.94k| } else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) { ------------------ | Branch (3364:16): [True: 97, False: 2.85k] ------------------ 3365| 97| unsigned i; 3366| 289k| for (i = 0; i < n; i++) ------------------ | Branch (3366:18): [True: 288k, False: 97] ------------------ 3367| 288k| do_free(allocator, ((ProtobufCBinaryData *) arr)[i].data); 3368| 2.85k| } else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) { ------------------ | Branch (3368:16): [True: 467, False: 2.38k] ------------------ 3369| 467| unsigned i; 3370| 76.4k| for (i = 0; i < n; i++) ------------------ | Branch (3370:18): [True: 75.9k, False: 467] ------------------ 3371| 75.9k| protobuf_c_message_free_unpacked( 3372| 75.9k| ((ProtobufCMessage **) arr)[i], 3373| 75.9k| allocator 3374| 75.9k| ); 3375| 467| } 3376| 2.99k| do_free(allocator, arr); 3377| 2.99k| } 3378| 450k| } else if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) { ------------------ | Branch (3378:14): [True: 17.5k, False: 432k] ------------------ 3379| 17.5k| char *str = STRUCT_MEMBER(char *, message, ------------------ | | 107| 17.5k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 17.5k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3380| 17.5k| desc->fields[f].offset); 3381| | 3382| 17.5k| if (str && str != desc->fields[f].default_value) ------------------ | Branch (3382:8): [True: 16.1k, False: 1.34k] | Branch (3382:15): [True: 1.04k, False: 15.1k] ------------------ 3383| 1.04k| do_free(allocator, str); 3384| 432k| } else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) { ------------------ | Branch (3384:14): [True: 35.0k, False: 397k] ------------------ 3385| 35.0k| void *data = STRUCT_MEMBER(ProtobufCBinaryData, message, ------------------ | | 107| 35.0k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 35.0k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3386| 35.0k| desc->fields[f].offset).data; 3387| 35.0k| const ProtobufCBinaryData *default_bd; 3388| | 3389| 35.0k| default_bd = desc->fields[f].default_value; 3390| 35.0k| if (data != NULL && ------------------ | Branch (3390:8): [True: 30.9k, False: 4.12k] ------------------ 3391| 30.9k| (default_bd == NULL || ------------------ | Branch (3391:9): [True: 0, False: 30.9k] ------------------ 3392| 30.9k| default_bd->data != data)) ------------------ | Branch (3392:9): [True: 753, False: 30.1k] ------------------ 3393| 753| { 3394| 753| do_free(allocator, data); 3395| 753| } 3396| 397k| } else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) { ------------------ | Branch (3396:14): [True: 152k, False: 245k] ------------------ 3397| 152k| ProtobufCMessage *sm; 3398| | 3399| 152k| sm = STRUCT_MEMBER(ProtobufCMessage *, message, ------------------ | | 107| 152k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 152k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 3400| 152k| desc->fields[f].offset); 3401| 152k| if (sm && sm != desc->fields[f].default_value) ------------------ | Branch (3401:8): [True: 1.61k, False: 150k] | Branch (3401:14): [True: 1.61k, False: 0] ------------------ 3402| 1.61k| protobuf_c_message_free_unpacked(sm, allocator); 3403| 152k| } 3404| 575k| } 3405| | 3406| 664k| for (f = 0; f < message->n_unknown_fields; f++) ------------------ | Branch (3406:14): [True: 569k, False: 95.3k] ------------------ 3407| 569k| do_free(allocator, message->unknown_fields[f].data); 3408| 95.3k| if (message->unknown_fields != NULL) ------------------ | Branch (3408:6): [True: 3.45k, False: 91.8k] ------------------ 3409| 3.45k| do_free(allocator, message->unknown_fields); 3410| | 3411| 95.3k| do_free(allocator, message); 3412| 95.3k|} protobuf_c_message_init: 3417| 95.8k|{ 3418| 95.8k| descriptor->message_init((ProtobufCMessage *) (message)); 3419| 95.8k|} protobuf-c.c:system_alloc: 152| 827k|{ 153| 827k| (void)allocator_data; 154| 827k| return malloc(size); 155| 827k|} protobuf-c.c:system_free: 159| 827k|{ 160| 827k| (void)allocator_data; 161| 827k| free(data); 162| 827k|} protobuf-c.c:do_alloc: 166| 827k|{ 167| 827k| return allocator->alloc(allocator->allocator_data, size); 168| 827k|} protobuf-c.c:do_free: 172| 1.10M|{ 173| 1.10M| if (data != NULL) ------------------ | Branch (173:6): [True: 827k, False: 280k] ------------------ 174| 827k| allocator->free(allocator->allocator_data, data); 175| 1.10M|} protobuf-c.c:parse_tag_and_wiretype: 2067| 7.63M|{ 2068| 7.63M| unsigned max_rv = len > 5 ? 5 : len; ------------------ | Branch (2068:20): [True: 7.54M, False: 85.5k] ------------------ 2069| 7.63M| uint32_t tag = (data[0] & 0x7f) >> 3; 2070| 7.63M| unsigned shift = 4; 2071| 7.63M| unsigned rv; 2072| | 2073| | /* 0 is not a valid tag value */ 2074| 7.63M| if ((data[0] & 0xf8) == 0) { ------------------ | Branch (2074:6): [True: 38, False: 7.63M] ------------------ 2075| 38| return 0; 2076| 38| } 2077| | 2078| 7.63M| *wiretype_out = data[0] & 7; 2079| 7.63M| if ((data[0] & 0x80) == 0) { ------------------ | Branch (2079:6): [True: 6.67M, False: 961k] ------------------ 2080| 6.67M| *tag_out = tag; 2081| 6.67M| return 1; 2082| 6.67M| } 2083| 1.13M| for (rv = 1; rv < max_rv; rv++) { ------------------ | Branch (2083:15): [True: 1.13M, False: 29] ------------------ 2084| 1.13M| if (data[rv] & 0x80) { ------------------ | Branch (2084:7): [True: 174k, False: 961k] ------------------ 2085| 174k| tag |= (data[rv] & 0x7f) << shift; 2086| 174k| shift += 7; 2087| 961k| } else { 2088| 961k| tag |= data[rv] << shift; 2089| 961k| *tag_out = tag; 2090| 961k| return rv + 1; 2091| 961k| } 2092| 1.13M| } 2093| 29| return 0; /* error: bad header */ 2094| 961k|} protobuf-c.c:int_range_lookup: 2023| 838k|{ 2024| 838k| unsigned n; 2025| 838k| unsigned start; 2026| | 2027| 838k| if (n_ranges == 0) ------------------ | Branch (2027:6): [True: 0, False: 838k] ------------------ 2028| 0| return -1; 2029| 838k| start = 0; 2030| 838k| n = n_ranges; 2031| 1.03M| while (n > 1) { ------------------ | Branch (2031:9): [True: 205k, False: 832k] ------------------ 2032| 205k| unsigned mid = start + n / 2; 2033| | 2034| 205k| if (value < ranges[mid].start_value) { ------------------ | Branch (2034:7): [True: 47.8k, False: 157k] ------------------ 2035| 47.8k| n = mid - start; 2036| 157k| } else if (value >= ranges[mid].start_value + ------------------ | Branch (2036:14): [True: 152k, False: 5.41k] ------------------ 2037| 157k| (int) (ranges[mid + 1].orig_index - 2038| 157k| ranges[mid].orig_index)) 2039| 152k| { 2040| 152k| unsigned new_start = mid + 1; 2041| 152k| n = start + n - new_start; 2042| 152k| start = new_start; 2043| 152k| } else 2044| 5.41k| return (value - ranges[mid].start_value) + 2045| 5.41k| ranges[mid].orig_index; 2046| 205k| } 2047| 832k| if (n > 0) { ------------------ | Branch (2047:6): [True: 680k, False: 152k] ------------------ 2048| 680k| unsigned start_orig_index = ranges[start].orig_index; 2049| 680k| unsigned range_size = 2050| 680k| ranges[start + 1].orig_index - start_orig_index; 2051| | 2052| 680k| if (ranges[start].start_value <= value && ------------------ | Branch (2052:7): [True: 652k, False: 28.0k] ------------------ 2053| 652k| value < (int) (ranges[start].start_value + range_size)) ------------------ | Branch (2053:7): [True: 206k, False: 446k] ------------------ 2054| 206k| { 2055| 206k| return (value - ranges[start].start_value) + 2056| 206k| start_orig_index; 2057| 206k| } 2058| 680k| } 2059| 626k| return -1; 2060| 832k|} protobuf-c.c:scan_length_prefixed_data: 2112| 681k|{ 2113| 681k| unsigned hdr_max = len < 5 ? len : 5; ------------------ | Branch (2113:21): [True: 4.93k, False: 676k] ------------------ 2114| 681k| unsigned hdr_len; 2115| 681k| size_t val = 0; 2116| 681k| unsigned i; 2117| 681k| unsigned shift = 0; 2118| | 2119| 686k| for (i = 0; i < hdr_max; i++) { ------------------ | Branch (2119:14): [True: 686k, False: 53] ------------------ 2120| 686k| val |= ((size_t)data[i] & 0x7f) << shift; 2121| 686k| shift += 7; 2122| 686k| if ((data[i] & 0x80) == 0) ------------------ | Branch (2122:7): [True: 681k, False: 5.60k] ------------------ 2123| 681k| break; 2124| 686k| } 2125| 681k| if (i == hdr_max) { ------------------ | Branch (2125:6): [True: 53, False: 681k] ------------------ 2126| 53| PROTOBUF_C_UNPACK_ERROR("error parsing length for length-prefixed data"); 2127| 53| return 0; 2128| 53| } 2129| 681k| hdr_len = i + 1; 2130| 681k| *prefix_len_out = hdr_len; 2131| 681k| if (val > INT_MAX) { ------------------ | Branch (2131:6): [True: 7, False: 681k] ------------------ 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| 7| PROTOBUF_C_UNPACK_ERROR("length prefix of %lu is too large", 2136| 7| (unsigned long int)val); 2137| 7| return 0; 2138| 7| } 2139| 681k| if (hdr_len + val > len) { ------------------ | Branch (2139:6): [True: 108, False: 680k] ------------------ 2140| 108| PROTOBUF_C_UNPACK_ERROR("data too short after length-prefix of %lu", 2141| 108| (unsigned long int)val); 2142| 108| return 0; 2143| 108| } 2144| 680k| return hdr_len + val; 2145| 681k|} protobuf-c.c:is_packable_type: 2877| 1.12M|{ 2878| 1.12M| return 2879| 1.12M| type != PROTOBUF_C_TYPE_STRING && ------------------ | Branch (2879:3): [True: 827k, False: 301k] ------------------ 2880| 827k| type != PROTOBUF_C_TYPE_BYTES && ------------------ | Branch (2880:3): [True: 243k, False: 583k] ------------------ 2881| 243k| type != PROTOBUF_C_TYPE_MESSAGE; ------------------ | Branch (2881:3): [True: 87.3k, False: 156k] ------------------ 2882| 1.12M|} protobuf-c.c:count_packed_elements: 2358| 51.6k|{ 2359| 51.6k| switch (type) { 2360| 6.63k| case PROTOBUF_C_TYPE_SFIXED32: ------------------ | Branch (2360:2): [True: 6.63k, False: 44.9k] ------------------ 2361| 8.42k| case PROTOBUF_C_TYPE_FIXED32: ------------------ | Branch (2361:2): [True: 1.79k, False: 49.8k] ------------------ 2362| 18.1k| case PROTOBUF_C_TYPE_FLOAT: ------------------ | Branch (2362:2): [True: 9.69k, False: 41.9k] ------------------ 2363| 18.1k| if (len % 4 != 0) { ------------------ | Branch (2363:7): [True: 2, False: 18.1k] ------------------ 2364| 2| PROTOBUF_C_UNPACK_ERROR("length must be a multiple of 4 for fixed-length 32-bit types"); 2365| 2| return FALSE; ------------------ | | 54| 2|#define FALSE 0 ------------------ 2366| 2| } 2367| 18.1k| *count_out = len / 4; 2368| 18.1k| return TRUE; ------------------ | | 53| 18.1k|#define TRUE 1 ------------------ 2369| 710| case PROTOBUF_C_TYPE_SFIXED64: ------------------ | Branch (2369:2): [True: 710, False: 50.8k] ------------------ 2370| 1.32k| case PROTOBUF_C_TYPE_FIXED64: ------------------ | Branch (2370:2): [True: 611, False: 50.9k] ------------------ 2371| 2.93k| case PROTOBUF_C_TYPE_DOUBLE: ------------------ | Branch (2371:2): [True: 1.61k, False: 49.9k] ------------------ 2372| 2.93k| if (len % 8 != 0) { ------------------ | Branch (2372:7): [True: 5, False: 2.92k] ------------------ 2373| 5| PROTOBUF_C_UNPACK_ERROR("length must be a multiple of 8 for fixed-length 64-bit types"); 2374| 5| return FALSE; ------------------ | | 54| 5|#define FALSE 0 ------------------ 2375| 5| } 2376| 2.92k| *count_out = len / 8; 2377| 2.92k| return TRUE; ------------------ | | 53| 2.92k|#define TRUE 1 ------------------ 2378| 1.53k| case PROTOBUF_C_TYPE_ENUM: ------------------ | Branch (2378:2): [True: 1.53k, False: 50.0k] ------------------ 2379| 5.87k| case PROTOBUF_C_TYPE_INT32: ------------------ | Branch (2379:2): [True: 4.33k, False: 47.2k] ------------------ 2380| 9.54k| case PROTOBUF_C_TYPE_SINT32: ------------------ | Branch (2380:2): [True: 3.66k, False: 47.9k] ------------------ 2381| 11.2k| case PROTOBUF_C_TYPE_UINT32: ------------------ | Branch (2381:2): [True: 1.67k, False: 49.9k] ------------------ 2382| 12.2k| case PROTOBUF_C_TYPE_INT64: ------------------ | Branch (2382:2): [True: 992, False: 50.6k] ------------------ 2383| 19.5k| case PROTOBUF_C_TYPE_SINT64: ------------------ | Branch (2383:2): [True: 7.34k, False: 44.2k] ------------------ 2384| 25.6k| case PROTOBUF_C_TYPE_UINT64: ------------------ | Branch (2384:2): [True: 6.11k, False: 45.4k] ------------------ 2385| 25.6k| *count_out = max_b128_numbers(len, data); 2386| 25.6k| return TRUE; ------------------ | | 53| 25.6k|#define TRUE 1 ------------------ 2387| 4.89k| case PROTOBUF_C_TYPE_BOOL: ------------------ | Branch (2387:2): [True: 4.89k, False: 46.7k] ------------------ 2388| 4.89k| *count_out = len; 2389| 4.89k| return TRUE; ------------------ | | 53| 4.89k|#define TRUE 1 ------------------ 2390| 0| case PROTOBUF_C_TYPE_STRING: ------------------ | Branch (2390:2): [True: 0, False: 51.6k] ------------------ 2391| 0| case PROTOBUF_C_TYPE_BYTES: ------------------ | Branch (2391:2): [True: 0, False: 51.6k] ------------------ 2392| 0| case PROTOBUF_C_TYPE_MESSAGE: ------------------ | Branch (2392:2): [True: 0, False: 51.6k] ------------------ 2393| 0| default: ------------------ | Branch (2393:2): [True: 0, False: 51.6k] ------------------ 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| 51.6k| } 2397| 51.6k|} protobuf-c.c:max_b128_numbers: 2149| 25.6k|{ 2150| 25.6k| size_t rv = 0; 2151| 11.6M| while (len--) ------------------ | Branch (2151:9): [True: 11.6M, False: 25.6k] ------------------ 2152| 11.6M| if ((*data++ & 0x80) == 0) ------------------ | Branch (2152:7): [True: 10.6M, False: 965k] ------------------ 2153| 10.6M| ++rv; 2154| 25.6k| return rv; 2155| 25.6k|} protobuf-c.c:sizeof_elt_in_repeated_array: 1238| 3.97M|{ 1239| 3.97M| switch (type) { ------------------ | Branch (1239:10): [True: 3.97M, False: 0] ------------------ 1240| 322k| case PROTOBUF_C_TYPE_SINT32: ------------------ | Branch (1240:2): [True: 322k, False: 3.65M] ------------------ 1241| 828k| case PROTOBUF_C_TYPE_INT32: ------------------ | Branch (1241:2): [True: 506k, False: 3.47M] ------------------ 1242| 837k| case PROTOBUF_C_TYPE_UINT32: ------------------ | Branch (1242:2): [True: 8.59k, False: 3.96M] ------------------ 1243| 843k| case PROTOBUF_C_TYPE_SFIXED32: ------------------ | Branch (1243:2): [True: 5.98k, False: 3.97M] ------------------ 1244| 847k| case PROTOBUF_C_TYPE_FIXED32: ------------------ | Branch (1244:2): [True: 4.02k, False: 3.97M] ------------------ 1245| 854k| case PROTOBUF_C_TYPE_FLOAT: ------------------ | Branch (1245:2): [True: 6.97k, False: 3.97M] ------------------ 1246| 898k| case PROTOBUF_C_TYPE_ENUM: ------------------ | Branch (1246:2): [True: 44.5k, False: 3.93M] ------------------ 1247| 898k| return 4; 1248| 22.0k| case PROTOBUF_C_TYPE_SINT64: ------------------ | Branch (1248:2): [True: 22.0k, False: 3.95M] ------------------ 1249| 2.49M| case PROTOBUF_C_TYPE_INT64: ------------------ | Branch (1249:2): [True: 2.47M, False: 1.50M] ------------------ 1250| 2.50M| case PROTOBUF_C_TYPE_UINT64: ------------------ | Branch (1250:2): [True: 7.46k, False: 3.97M] ------------------ 1251| 2.51M| case PROTOBUF_C_TYPE_SFIXED64: ------------------ | Branch (1251:2): [True: 6.42k, False: 3.97M] ------------------ 1252| 2.51M| case PROTOBUF_C_TYPE_FIXED64: ------------------ | Branch (1252:2): [True: 2.85k, False: 3.97M] ------------------ 1253| 2.51M| case PROTOBUF_C_TYPE_DOUBLE: ------------------ | Branch (1253:2): [True: 4.75k, False: 3.97M] ------------------ 1254| 2.51M| return 8; 1255| 52.0k| case PROTOBUF_C_TYPE_BOOL: ------------------ | Branch (1255:2): [True: 52.0k, False: 3.92M] ------------------ 1256| 52.0k| return sizeof(protobuf_c_boolean); 1257| 136k| case PROTOBUF_C_TYPE_STRING: ------------------ | Branch (1257:2): [True: 136k, False: 3.84M] ------------------ 1258| 214k| case PROTOBUF_C_TYPE_MESSAGE: ------------------ | Branch (1258:2): [True: 77.8k, False: 3.89M] ------------------ 1259| 214k| return sizeof(void *); 1260| 293k| case PROTOBUF_C_TYPE_BYTES: ------------------ | Branch (1260:2): [True: 293k, False: 3.68M] ------------------ 1261| 293k| return sizeof(ProtobufCBinaryData); 1262| 3.97M| } 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| 5.07M|{ 2889| 5.07M| const ProtobufCFieldDescriptor *field = scanned_member->field; 2890| 5.07M| void *member; 2891| | 2892| 5.07M| if (field == NULL) { ------------------ | Branch (2892:6): [True: 569k, False: 4.50M] ------------------ 2893| 569k| ProtobufCMessageUnknownField *ufield = 2894| 569k| message->unknown_fields + 2895| 569k| (message->n_unknown_fields++); 2896| 569k| ufield->tag = scanned_member->tag; 2897| 569k| ufield->wire_type = scanned_member->wire_type; 2898| 569k| ufield->len = scanned_member->len; 2899| 569k| ufield->data = do_alloc(allocator, scanned_member->len); 2900| 569k| if (ufield->data == NULL) ------------------ | Branch (2900:7): [True: 0, False: 569k] ------------------ 2901| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2902| 569k| memcpy(ufield->data, scanned_member->data, ufield->len); 2903| 569k| return TRUE; ------------------ | | 53| 569k|#define TRUE 1 ------------------ 2904| 569k| } 2905| 4.50M| member = (char *) message + field->offset; 2906| 4.50M| switch (field->label) { ------------------ | Branch (2906:10): [True: 4.50M, False: 0] ------------------ 2907| 629k| case PROTOBUF_C_LABEL_REQUIRED: ------------------ | Branch (2907:2): [True: 629k, False: 3.87M] ------------------ 2908| 629k| return parse_required_member(scanned_member, member, 2909| 629k| allocator, TRUE); ------------------ | | 53| 629k|#define TRUE 1 ------------------ 2910| 28.9k| case PROTOBUF_C_LABEL_OPTIONAL: ------------------ | Branch (2910:2): [True: 28.9k, False: 4.47M] ------------------ 2911| 28.9k| case PROTOBUF_C_LABEL_NONE: ------------------ | Branch (2911:2): [True: 0, False: 4.50M] ------------------ 2912| 28.9k| if (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_ONEOF)) { ------------------ | Branch (2912:7): [True: 0, False: 28.9k] ------------------ 2913| 0| return parse_oneof_member(scanned_member, member, 2914| 0| message, allocator); 2915| 28.9k| } else { 2916| 28.9k| return parse_optional_member(scanned_member, member, 2917| 28.9k| message, allocator); 2918| 28.9k| } 2919| 3.84M| case PROTOBUF_C_LABEL_REPEATED: ------------------ | Branch (2919:2): [True: 3.84M, False: 658k] ------------------ 2920| 3.84M| if (scanned_member->wire_type == ------------------ | Branch (2920:7): [True: 534k, False: 3.31M] ------------------ 2921| 3.84M| PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED && 2922| 534k| (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED) || ------------------ | Branch (2922:8): [True: 0, False: 534k] ------------------ 2923| 534k| is_packable_type(field->type))) ------------------ | Branch (2923:8): [True: 35.7k, False: 498k] ------------------ 2924| 35.7k| { 2925| 35.7k| return parse_packed_repeated_member(scanned_member, 2926| 35.7k| member, message); 2927| 3.81M| } else { 2928| 3.81M| return parse_repeated_member(scanned_member, 2929| 3.81M| member, message, 2930| 3.81M| allocator); 2931| 3.81M| } 2932| 4.50M| } 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| 4.46M|{ 2501| 4.46M| unsigned len = scanned_member->len; 2502| 4.46M| const uint8_t *data = scanned_member->data; 2503| 4.46M| uint8_t wire_type = scanned_member->wire_type; 2504| | 2505| 4.46M| switch (scanned_member->field->type) { ------------------ | Branch (2505:10): [True: 4.46M, False: 0] ------------------ 2506| 39.6k| case PROTOBUF_C_TYPE_ENUM: ------------------ | Branch (2506:2): [True: 39.6k, False: 4.42M] ------------------ 2507| 1.07M| case PROTOBUF_C_TYPE_INT32: ------------------ | Branch (2507:2): [True: 1.03M, False: 3.43M] ------------------ 2508| 1.07M| if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) ------------------ | Branch (2508:7): [True: 17, False: 1.07M] ------------------ 2509| 17| return FALSE; ------------------ | | 54| 17|#define FALSE 0 ------------------ 2510| 1.07M| *(int32_t *) member = parse_int32(len, data); 2511| 1.07M| return TRUE; ------------------ | | 53| 1.07M|#define TRUE 1 ------------------ 2512| 5.66k| case PROTOBUF_C_TYPE_UINT32: ------------------ | Branch (2512:2): [True: 5.66k, False: 4.46M] ------------------ 2513| 5.66k| if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) ------------------ | Branch (2513:7): [True: 2, False: 5.66k] ------------------ 2514| 2| return FALSE; ------------------ | | 54| 2|#define FALSE 0 ------------------ 2515| 5.66k| *(uint32_t *) member = parse_uint32(len, data); 2516| 5.66k| return TRUE; ------------------ | | 53| 5.66k|#define TRUE 1 ------------------ 2517| 318k| case PROTOBUF_C_TYPE_SINT32: ------------------ | Branch (2517:2): [True: 318k, False: 4.15M] ------------------ 2518| 318k| if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) ------------------ | Branch (2518:7): [True: 2, False: 318k] ------------------ 2519| 2| return FALSE; ------------------ | | 54| 2|#define FALSE 0 ------------------ 2520| 318k| *(int32_t *) member = unzigzag32(parse_uint32(len, data)); 2521| 318k| return TRUE; ------------------ | | 53| 318k|#define TRUE 1 ------------------ 2522| 826| case PROTOBUF_C_TYPE_SFIXED32: ------------------ | Branch (2522:2): [True: 826, False: 4.46M] ------------------ 2523| 1.46k| case PROTOBUF_C_TYPE_FIXED32: ------------------ | Branch (2523:2): [True: 636, False: 4.46M] ------------------ 2524| 1.69k| case PROTOBUF_C_TYPE_FLOAT: ------------------ | Branch (2524:2): [True: 229, False: 4.46M] ------------------ 2525| 1.69k| if (wire_type != PROTOBUF_C_WIRE_TYPE_32BIT) ------------------ | Branch (2525:7): [True: 38, False: 1.65k] ------------------ 2526| 38| return FALSE; ------------------ | | 54| 38|#define FALSE 0 ------------------ 2527| 1.65k| *(uint32_t *) member = parse_fixed_uint32(data); 2528| 1.65k| return TRUE; ------------------ | | 53| 1.65k|#define TRUE 1 ------------------ 2529| 2.47M| case PROTOBUF_C_TYPE_INT64: ------------------ | Branch (2529:2): [True: 2.47M, False: 1.99M] ------------------ 2530| 2.47M| case PROTOBUF_C_TYPE_UINT64: ------------------ | Branch (2530:2): [True: 1.72k, False: 4.46M] ------------------ 2531| 2.47M| if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) ------------------ | Branch (2531:7): [True: 3, False: 2.47M] ------------------ 2532| 3| return FALSE; ------------------ | | 54| 3|#define FALSE 0 ------------------ 2533| 2.47M| *(uint64_t *) member = parse_uint64(len, data); 2534| 2.47M| return TRUE; ------------------ | | 53| 2.47M|#define TRUE 1 ------------------ 2535| 14.6k| case PROTOBUF_C_TYPE_SINT64: ------------------ | Branch (2535:2): [True: 14.6k, False: 4.45M] ------------------ 2536| 14.6k| if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) ------------------ | Branch (2536:7): [True: 5, False: 14.6k] ------------------ 2537| 5| return FALSE; ------------------ | | 54| 5|#define FALSE 0 ------------------ 2538| 14.6k| *(int64_t *) member = unzigzag64(parse_uint64(len, data)); 2539| 14.6k| return TRUE; ------------------ | | 53| 14.6k|#define TRUE 1 ------------------ 2540| 4.25k| case PROTOBUF_C_TYPE_SFIXED64: ------------------ | Branch (2540:2): [True: 4.25k, False: 4.46M] ------------------ 2541| 4.86k| case PROTOBUF_C_TYPE_FIXED64: ------------------ | Branch (2541:2): [True: 606, False: 4.46M] ------------------ 2542| 6.48k| case PROTOBUF_C_TYPE_DOUBLE: ------------------ | Branch (2542:2): [True: 1.62k, False: 4.46M] ------------------ 2543| 6.48k| if (wire_type != PROTOBUF_C_WIRE_TYPE_64BIT) ------------------ | Branch (2543:7): [True: 37, False: 6.44k] ------------------ 2544| 37| return FALSE; ------------------ | | 54| 37|#define FALSE 0 ------------------ 2545| 6.44k| *(uint64_t *) member = parse_fixed_uint64(data); 2546| 6.44k| return TRUE; ------------------ | | 53| 6.44k|#define TRUE 1 ------------------ 2547| 45.8k| case PROTOBUF_C_TYPE_BOOL: ------------------ | Branch (2547:2): [True: 45.8k, False: 4.42M] ------------------ 2548| 45.8k| *(protobuf_c_boolean *) member = parse_boolean(len, data); 2549| 45.8k| return TRUE; ------------------ | | 53| 45.8k|#define TRUE 1 ------------------ 2550| 134k| case PROTOBUF_C_TYPE_STRING: { ------------------ | Branch (2550:2): [True: 134k, False: 4.33M] ------------------ 2551| 134k| char **pstr = member; 2552| 134k| unsigned pref_len = scanned_member->length_prefix_len; 2553| | 2554| 134k| if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) ------------------ | Branch (2554:7): [True: 8, False: 134k] ------------------ 2555| 8| return FALSE; ------------------ | | 54| 8|#define FALSE 0 ------------------ 2556| | 2557| 134k| if (maybe_clear && *pstr != NULL) { ------------------ | Branch (2557:7): [True: 1.70k, False: 133k] | Branch (2557:22): [True: 1.70k, False: 0] ------------------ 2558| 1.70k| const char *def = scanned_member->field->default_value; 2559| 1.70k| if (*pstr != def) ------------------ | Branch (2559:8): [True: 654, False: 1.04k] ------------------ 2560| 654| do_free(allocator, *pstr); 2561| 1.70k| } 2562| 134k| *pstr = do_alloc(allocator, len - pref_len + 1); 2563| 134k| if (*pstr == NULL) ------------------ | Branch (2563:7): [True: 0, False: 134k] ------------------ 2564| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2565| 134k| memcpy(*pstr, data + pref_len, len - pref_len); 2566| 134k| (*pstr)[len - pref_len] = 0; 2567| 134k| return TRUE; ------------------ | | 53| 134k|#define TRUE 1 ------------------ 2568| 134k| } 2569| 296k| case PROTOBUF_C_TYPE_BYTES: { ------------------ | Branch (2569:2): [True: 296k, False: 4.17M] ------------------ 2570| 296k| ProtobufCBinaryData *bd = member; 2571| 296k| const ProtobufCBinaryData *def_bd; 2572| 296k| unsigned pref_len = scanned_member->length_prefix_len; 2573| | 2574| 296k| if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) ------------------ | Branch (2574:7): [True: 16, False: 296k] ------------------ 2575| 16| return FALSE; ------------------ | | 54| 16|#define FALSE 0 ------------------ 2576| | 2577| 296k| def_bd = scanned_member->field->default_value; 2578| 296k| if (maybe_clear && ------------------ | Branch (2578:7): [True: 7.54k, False: 288k] ------------------ 2579| 7.54k| bd->data != NULL && ------------------ | Branch (2579:7): [True: 6.85k, False: 691] ------------------ 2580| 6.85k| (def_bd == NULL || bd->data != def_bd->data)) ------------------ | Branch (2580:8): [True: 0, False: 6.85k] | Branch (2580:26): [True: 3.98k, False: 2.86k] ------------------ 2581| 3.98k| { 2582| 3.98k| do_free(allocator, bd->data); 2583| 3.98k| } 2584| 296k| if (len > pref_len) { ------------------ | Branch (2584:7): [True: 13.3k, False: 283k] ------------------ 2585| 13.3k| bd->data = do_alloc(allocator, len - pref_len); 2586| 13.3k| if (bd->data == NULL) ------------------ | Branch (2586:8): [True: 0, False: 13.3k] ------------------ 2587| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2588| 13.3k| memcpy(bd->data, data + pref_len, len - pref_len); 2589| 283k| } else { 2590| 283k| bd->data = NULL; 2591| 283k| } 2592| 296k| bd->len = len - pref_len; 2593| 296k| return TRUE; ------------------ | | 53| 296k|#define TRUE 1 ------------------ 2594| 296k| } 2595| 93.7k| case PROTOBUF_C_TYPE_MESSAGE: { ------------------ | Branch (2595:2): [True: 93.7k, False: 4.37M] ------------------ 2596| 93.7k| ProtobufCMessage **pmessage = member; 2597| 93.7k| ProtobufCMessage *subm; 2598| 93.7k| const ProtobufCMessage *def_mess; 2599| 93.7k| protobuf_c_boolean merge_successful = TRUE; ------------------ | | 53| 93.7k|#define TRUE 1 ------------------ 2600| 93.7k| unsigned pref_len = scanned_member->length_prefix_len; 2601| | 2602| 93.7k| if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) ------------------ | Branch (2602:7): [True: 10, False: 93.7k] ------------------ 2603| 10| return FALSE; ------------------ | | 54| 10|#define FALSE 0 ------------------ 2604| | 2605| 93.7k| def_mess = scanned_member->field->default_value; 2606| 93.7k| if (len >= pref_len) ------------------ | Branch (2606:7): [True: 93.7k, False: 0] ------------------ 2607| 93.7k| subm = protobuf_c_message_unpack(scanned_member->field->descriptor, 2608| 93.7k| allocator, 2609| 93.7k| len - pref_len, 2610| 93.7k| data + pref_len); 2611| 0| else 2612| 0| subm = NULL; 2613| | 2614| 93.7k| if (maybe_clear && ------------------ | Branch (2614:7): [True: 17.5k, False: 76.1k] ------------------ 2615| 17.5k| *pmessage != NULL && ------------------ | Branch (2615:7): [True: 15.8k, False: 1.64k] ------------------ 2616| 15.8k| *pmessage != def_mess) ------------------ | Branch (2616:7): [True: 15.8k, False: 0] ------------------ 2617| 15.8k| { 2618| 15.8k| if (subm != NULL) ------------------ | Branch (2618:8): [True: 15.8k, False: 20] ------------------ 2619| 15.8k| merge_successful = merge_messages(*pmessage, subm, allocator); 2620| | /* Delete the previous message */ 2621| 15.8k| protobuf_c_message_free_unpacked(*pmessage, allocator); 2622| 15.8k| } 2623| 93.7k| *pmessage = subm; 2624| 93.7k| if (subm == NULL || !merge_successful) ------------------ | Branch (2624:7): [True: 226, False: 93.4k] | Branch (2624:23): [True: 0, False: 93.4k] ------------------ 2625| 226| return FALSE; ------------------ | | 54| 226|#define FALSE 0 ------------------ 2626| 93.4k| return TRUE; ------------------ | | 53| 93.4k|#define TRUE 1 ------------------ 2627| 93.7k| } 2628| 4.46M| } 2629| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2630| 4.46M|} protobuf-c.c:parse_int32: 2419| 3.70M|{ 2420| 3.70M| return parse_uint32(len, data); 2421| 3.70M|} 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: 366k, False: 11.7M] ------------------ 2404| 366k| rv |= ((uint32_t) (data[1] & 0x7f) << 7); 2405| 366k| if (len > 2) { ------------------ | Branch (2405:7): [True: 124k, False: 242k] ------------------ 2406| 124k| rv |= ((uint32_t) (data[2] & 0x7f) << 14); 2407| 124k| if (len > 3) { ------------------ | Branch (2407:8): [True: 70.2k, False: 53.9k] ------------------ 2408| 70.2k| rv |= ((uint32_t) (data[3] & 0x7f) << 21); 2409| 70.2k| if (len > 4) ------------------ | Branch (2409:9): [True: 20.6k, False: 49.5k] ------------------ 2410| 20.6k| rv |= ((uint32_t) (data[4]) << 28); 2411| 70.2k| } 2412| 124k| } 2413| 366k| } 2414| 12.1M| return rv; 2415| 12.1M|} protobuf-c.c:unzigzag32: 2425| 1.26M|{ 2426| | // Note: Using unsigned types prevents undefined behavior 2427| 1.26M| return (int32_t)((v >> 1) ^ -(v & 1)); 2428| 1.26M|} protobuf-c.c:parse_fixed_uint32: 2432| 1.65k|{ 2433| 1.65k|#if !defined(WORDS_BIGENDIAN) 2434| 1.65k| uint32_t t; 2435| 1.65k| memcpy(&t, data, 4); 2436| 1.65k| 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| 1.65k|} protobuf-c.c:parse_uint64: 2447| 5.60M|{ 2448| 5.60M| unsigned shift, i; 2449| 5.60M| uint64_t rv; 2450| | 2451| 5.60M| if (len < 5) ------------------ | Branch (2451:6): [True: 5.59M, False: 7.69k] ------------------ 2452| 5.59M| return parse_uint32(len, data); 2453| 7.69k| rv = ((uint64_t) (data[0] & 0x7f)) | 2454| 7.69k| ((uint64_t) (data[1] & 0x7f) << 7) | 2455| 7.69k| ((uint64_t) (data[2] & 0x7f) << 14) | 2456| 7.69k| ((uint64_t) (data[3] & 0x7f) << 21); 2457| 7.69k| shift = 28; 2458| 29.3k| for (i = 4; i < len; i++) { ------------------ | Branch (2458:14): [True: 21.6k, False: 7.69k] ------------------ 2459| 21.6k| rv |= (((uint64_t) (data[i] & 0x7f)) << shift); 2460| 21.6k| shift += 7; 2461| 21.6k| } 2462| 7.69k| return rv; 2463| 5.60M|} protobuf-c.c:unzigzag64: 2467| 1.41M|{ 2468| | // Note: Using unsigned types prevents undefined behavior 2469| 1.41M| return (int64_t)((v >> 1) ^ -(v & 1)); 2470| 1.41M|} protobuf-c.c:parse_fixed_uint64: 2474| 6.44k|{ 2475| 6.44k|#if !defined(WORDS_BIGENDIAN) 2476| 6.44k| uint64_t t; 2477| 6.44k| memcpy(&t, data, 8); 2478| 6.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| 6.44k|} protobuf-c.c:parse_boolean: 2487| 382k|{ 2488| 382k| unsigned i; 2489| 396k| for (i = 0; i < len; i++) ------------------ | Branch (2489:14): [True: 384k, False: 11.8k] ------------------ 2490| 384k| if (data[i] & 0x7f) ------------------ | Branch (2490:7): [True: 370k, False: 14.4k] ------------------ 2491| 370k| return TRUE; ------------------ | | 53| 370k|#define TRUE 1 ------------------ 2492| 11.8k| return FALSE; ------------------ | | 54| 11.8k|#define FALSE 0 ------------------ 2493| 382k|} protobuf-c.c:merge_messages: 2177| 15.8k|{ 2178| 15.8k| unsigned i; 2179| 15.8k| const ProtobufCFieldDescriptor *fields = 2180| 15.8k| latter_msg->descriptor->fields; 2181| 95.2k| for (i = 0; i < latter_msg->descriptor->n_fields; i++) { ------------------ | Branch (2181:14): [True: 79.3k, False: 15.8k] ------------------ 2182| 79.3k| if (fields[i].label == PROTOBUF_C_LABEL_REPEATED) { ------------------ | Branch (2182:7): [True: 15.8k, False: 63.4k] ------------------ 2183| 15.8k| size_t *n_earlier = 2184| 15.8k| STRUCT_MEMBER_PTR(size_t, earlier_msg, ------------------ | | 116| 15.8k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 15.8k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2185| 15.8k| fields[i].quantifier_offset); 2186| 15.8k| uint8_t **p_earlier = 2187| 15.8k| STRUCT_MEMBER_PTR(uint8_t *, earlier_msg, ------------------ | | 116| 15.8k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 15.8k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2188| 15.8k| fields[i].offset); 2189| 15.8k| size_t *n_latter = 2190| 15.8k| STRUCT_MEMBER_PTR(size_t, latter_msg, ------------------ | | 116| 15.8k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 15.8k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2191| 15.8k| fields[i].quantifier_offset); 2192| 15.8k| uint8_t **p_latter = 2193| 15.8k| STRUCT_MEMBER_PTR(uint8_t *, latter_msg, ------------------ | | 116| 15.8k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 15.8k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2194| 15.8k| fields[i].offset); 2195| | 2196| 15.8k| if (*n_earlier > 0) { ------------------ | Branch (2196:8): [True: 3.15k, False: 12.7k] ------------------ 2197| 3.15k| if (*n_latter > 0) { ------------------ | Branch (2197:9): [True: 1.41k, False: 1.74k] ------------------ 2198| | /* Concatenate the repeated field */ 2199| 1.41k| size_t el_size = 2200| 1.41k| sizeof_elt_in_repeated_array(fields[i].type); 2201| 1.41k| uint8_t *new_field; 2202| | 2203| 1.41k| new_field = do_alloc(allocator, 2204| 1.41k| (*n_earlier + *n_latter) * el_size); 2205| 1.41k| if (!new_field) ------------------ | Branch (2205:10): [True: 0, False: 1.41k] ------------------ 2206| 0| return FALSE; ------------------ | | 54| 0|#define FALSE 0 ------------------ 2207| | 2208| 1.41k| memcpy(new_field, *p_earlier, 2209| 1.41k| *n_earlier * el_size); 2210| 1.41k| memcpy(new_field + 2211| 1.41k| *n_earlier * el_size, 2212| 1.41k| *p_latter, 2213| 1.41k| *n_latter * el_size); 2214| | 2215| 1.41k| do_free(allocator, *p_latter); 2216| 1.41k| do_free(allocator, *p_earlier); 2217| 1.41k| *p_latter = new_field; 2218| 1.41k| *n_latter = *n_earlier + *n_latter; 2219| 1.74k| } else { 2220| | /* Zero copy the repeated field from the earlier message */ 2221| 1.74k| *n_latter = *n_earlier; 2222| 1.74k| *p_latter = *p_earlier; 2223| 1.74k| } 2224| | /* Make sure the field does not get double freed */ 2225| 3.15k| *n_earlier = 0; 2226| 3.15k| *p_earlier = 0; 2227| 3.15k| } 2228| 63.4k| } else if (fields[i].label == PROTOBUF_C_LABEL_OPTIONAL || ------------------ | Branch (2228:14): [True: 63.4k, False: 0] ------------------ 2229| 63.4k| fields[i].label == PROTOBUF_C_LABEL_NONE) { ------------------ | Branch (2229:7): [True: 0, False: 0] ------------------ 2230| 63.4k| const ProtobufCFieldDescriptor *field; 2231| 63.4k| uint32_t *earlier_case_p = STRUCT_MEMBER_PTR(uint32_t, ------------------ | | 116| 63.4k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 63.4k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2232| 63.4k| earlier_msg, 2233| 63.4k| fields[i]. 2234| 63.4k| quantifier_offset); 2235| 63.4k| uint32_t *latter_case_p = STRUCT_MEMBER_PTR(uint32_t, ------------------ | | 116| 63.4k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 63.4k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2236| 63.4k| latter_msg, 2237| 63.4k| fields[i]. 2238| 63.4k| quantifier_offset); 2239| 63.4k| protobuf_c_boolean need_to_merge = FALSE; ------------------ | | 54| 63.4k|#define FALSE 0 ------------------ 2240| 63.4k| void *earlier_elem; 2241| 63.4k| void *latter_elem; 2242| 63.4k| const void *def_val; 2243| | 2244| 63.4k| if (fields[i].flags & PROTOBUF_C_FIELD_FLAG_ONEOF) { ------------------ | Branch (2244:8): [True: 0, False: 63.4k] ------------------ 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| 63.4k| } else { 2263| 63.4k| field = &fields[i]; 2264| 63.4k| } 2265| | 2266| 63.4k| earlier_elem = STRUCT_MEMBER_P(earlier_msg, field->offset); ------------------ | | 98| 63.4k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) ------------------ 2267| 63.4k| latter_elem = STRUCT_MEMBER_P(latter_msg, field->offset); ------------------ | | 98| 63.4k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) ------------------ 2268| 63.4k| def_val = field->default_value; 2269| | 2270| 63.4k| switch (field->type) { 2271| 0| case PROTOBUF_C_TYPE_MESSAGE: { ------------------ | Branch (2271:4): [True: 0, False: 63.4k] ------------------ 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| 31.7k| case PROTOBUF_C_TYPE_BYTES: { ------------------ | Branch (2287:4): [True: 31.7k, False: 31.7k] ------------------ 2288| 31.7k| uint8_t *e_data = 2289| 31.7k| ((ProtobufCBinaryData *) earlier_elem)->data; 2290| 31.7k| uint8_t *l_data = 2291| 31.7k| ((ProtobufCBinaryData *) latter_elem)->data; 2292| 31.7k| const ProtobufCBinaryData *d_bd = 2293| 31.7k| (ProtobufCBinaryData *) def_val; 2294| | 2295| 31.7k| need_to_merge = 2296| 31.7k| (e_data != NULL && ------------------ | Branch (2296:7): [True: 30.7k, False: 1.03k] ------------------ 2297| 30.7k| (d_bd == NULL || ------------------ | Branch (2297:8): [True: 0, False: 30.7k] ------------------ 2298| 30.7k| e_data != d_bd->data)) && ------------------ | Branch (2298:8): [True: 3.10k, False: 27.6k] ------------------ 2299| 3.10k| (l_data == NULL || ------------------ | Branch (2299:7): [True: 736, False: 2.37k] ------------------ 2300| 2.37k| (d_bd != NULL && ------------------ | Branch (2300:8): [True: 2.37k, False: 0] ------------------ 2301| 2.37k| l_data == d_bd->data)); ------------------ | Branch (2301:8): [True: 2.01k, False: 357] ------------------ 2302| 31.7k| break; 2303| 0| } 2304| 15.8k| case PROTOBUF_C_TYPE_STRING: { ------------------ | Branch (2304:4): [True: 15.8k, False: 47.6k] ------------------ 2305| 15.8k| char *e_str = *(char **) earlier_elem; 2306| 15.8k| char *l_str = *(char **) latter_elem; 2307| 15.8k| const char *d_str = def_val; 2308| | 2309| 15.8k| need_to_merge = e_str != d_str && l_str == d_str; ------------------ | Branch (2309:21): [True: 2.09k, False: 13.7k] | Branch (2309:39): [True: 1.34k, False: 755] ------------------ 2310| 15.8k| break; 2311| 0| } 2312| 15.8k| default: { ------------------ | Branch (2312:4): [True: 15.8k, False: 47.6k] ------------------ 2313| | /* Could be has field or case enum, the logic is 2314| | * equivalent, since 0 (FALSE) means not set for 2315| | * oneof */ 2316| 15.8k| need_to_merge = (*earlier_case_p != 0) && ------------------ | Branch (2316:21): [True: 911, False: 14.9k] ------------------ 2317| 911| (*latter_case_p == 0); ------------------ | Branch (2317:7): [True: 891, False: 20] ------------------ 2318| 15.8k| break; 2319| 0| } 2320| 63.4k| } 2321| | 2322| 63.4k| if (need_to_merge) { ------------------ | Branch (2322:8): [True: 4.98k, False: 58.5k] ------------------ 2323| 4.98k| size_t el_size = 2324| 4.98k| sizeof_elt_in_repeated_array(field->type); 2325| 4.98k| 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.98k| memset(earlier_elem, 0, el_size); 2334| | 2335| 4.98k| if (field->quantifier_offset != 0) { ------------------ | Branch (2335:9): [True: 3.64k, False: 1.34k] ------------------ 2336| | /* Set the has field or the case enum, 2337| | * if applicable */ 2338| 3.64k| *latter_case_p = *earlier_case_p; 2339| 3.64k| *earlier_case_p = 0; 2340| 3.64k| } 2341| 4.98k| } 2342| 63.4k| } 2343| 79.3k| } 2344| 15.8k| return TRUE; ------------------ | | 53| 15.8k|#define TRUE 1 ------------------ 2345| 15.8k|} protobuf-c.c:parse_optional_member: 2699| 28.9k|{ 2700| 28.9k| if (!parse_required_member(scanned_member, member, allocator, TRUE)) ------------------ | | 53| 28.9k|#define TRUE 1 ------------------ | Branch (2700:6): [True: 53, False: 28.8k] ------------------ 2701| 53| return FALSE; ------------------ | | 54| 53|#define FALSE 0 ------------------ 2702| 28.8k| if (scanned_member->field->quantifier_offset != 0) ------------------ | Branch (2702:6): [True: 9.65k, False: 19.2k] ------------------ 2703| 9.65k| STRUCT_MEMBER(protobuf_c_boolean, ------------------ | | 107| 9.65k| (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 9.65k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2704| 9.65k| message, 2705| 9.65k| scanned_member->field->quantifier_offset) = TRUE; ------------------ | | 53| 9.65k|#define TRUE 1 ------------------ 2706| 28.8k| return TRUE; ------------------ | | 53| 28.8k|#define TRUE 1 ------------------ 2707| 28.9k|} protobuf-c.c:parse_packed_repeated_member: 2747| 35.7k|{ 2748| 35.7k| const ProtobufCFieldDescriptor *field = scanned_member->field; 2749| 35.7k| size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset); ------------------ | | 116| 35.7k| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 35.7k| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2750| 35.7k| size_t siz = sizeof_elt_in_repeated_array(field->type); 2751| 35.7k| void *array = *(char **) member + siz * (*p_n); 2752| 35.7k| const uint8_t *at = scanned_member->data + scanned_member->length_prefix_len; 2753| 35.7k| size_t rem = scanned_member->len - scanned_member->length_prefix_len; 2754| 35.7k| size_t count = 0; 2755| |#if defined(WORDS_BIGENDIAN) 2756| | unsigned i; 2757| |#endif 2758| | 2759| 35.7k| switch (field->type) { 2760| 3.43k| case PROTOBUF_C_TYPE_SFIXED32: ------------------ | Branch (2760:2): [True: 3.43k, False: 32.3k] ------------------ 2761| 5.08k| case PROTOBUF_C_TYPE_FIXED32: ------------------ | Branch (2761:2): [True: 1.65k, False: 34.0k] ------------------ 2762| 10.1k| case PROTOBUF_C_TYPE_FLOAT: ------------------ | Branch (2762:2): [True: 5.01k, False: 30.7k] ------------------ 2763| 10.1k| count = (scanned_member->len - scanned_member->length_prefix_len) / 4; 2764| 10.1k|#if !defined(WORDS_BIGENDIAN) 2765| 10.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| 440| case PROTOBUF_C_TYPE_SFIXED64: ------------------ | Branch (2773:2): [True: 440, False: 35.2k] ------------------ 2774| 954| case PROTOBUF_C_TYPE_FIXED64: ------------------ | Branch (2774:2): [True: 514, False: 35.2k] ------------------ 2775| 2.35k| case PROTOBUF_C_TYPE_DOUBLE: ------------------ | Branch (2775:2): [True: 1.40k, False: 34.3k] ------------------ 2776| 2.35k| count = (scanned_member->len - scanned_member->length_prefix_len) / 8; 2777| 2.35k|#if !defined(WORDS_BIGENDIAN) 2778| 2.35k| 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.35k| case PROTOBUF_C_TYPE_ENUM: ------------------ | Branch (2786:2): [True: 1.35k, False: 34.3k] ------------------ 2787| 4.76k| case PROTOBUF_C_TYPE_INT32: ------------------ | Branch (2787:2): [True: 3.41k, False: 32.3k] ------------------ 2788| 2.63M| while (rem > 0) { ------------------ | Branch (2788:10): [True: 2.62M, False: 4.75k] ------------------ 2789| 2.62M| unsigned s = scan_varint(rem, at); 2790| 2.62M| if (s == 0) { ------------------ | Branch (2790:8): [True: 15, False: 2.62M] ------------------ 2791| 15| PROTOBUF_C_UNPACK_ERROR("bad packed-repeated int32 value"); 2792| 15| return FALSE; ------------------ | | 54| 15|#define FALSE 0 ------------------ 2793| 15| } 2794| 2.62M| ((int32_t *) array)[count++] = parse_int32(s, at); 2795| 2.62M| at += s; 2796| 2.62M| rem -= s; 2797| 2.62M| } 2798| 4.75k| break; 2799| 4.75k| case PROTOBUF_C_TYPE_SINT32: ------------------ | Branch (2799:2): [True: 2.39k, False: 33.3k] ------------------ 2800| 951k| while (rem > 0) { ------------------ | Branch (2800:10): [True: 948k, False: 2.35k] ------------------ 2801| 948k| unsigned s = scan_varint(rem, at); 2802| 948k| if (s == 0) { ------------------ | Branch (2802:8): [True: 36, False: 948k] ------------------ 2803| 36| PROTOBUF_C_UNPACK_ERROR("bad packed-repeated sint32 value"); 2804| 36| return FALSE; ------------------ | | 54| 36|#define FALSE 0 ------------------ 2805| 36| } 2806| 948k| ((int32_t *) array)[count++] = unzigzag32(parse_uint32(s, at)); 2807| 948k| at += s; 2808| 948k| rem -= s; 2809| 948k| } 2810| 2.35k| break; 2811| 2.35k| case PROTOBUF_C_TYPE_UINT32: ------------------ | Branch (2811:2): [True: 1.20k, False: 34.5k] ------------------ 2812| 1.52M| while (rem > 0) { ------------------ | Branch (2812:10): [True: 1.52M, False: 1.17k] ------------------ 2813| 1.52M| unsigned s = scan_varint(rem, at); 2814| 1.52M| if (s == 0) { ------------------ | Branch (2814:8): [True: 28, False: 1.52M] ------------------ 2815| 28| PROTOBUF_C_UNPACK_ERROR("bad packed-repeated enum or uint32 value"); 2816| 28| return FALSE; ------------------ | | 54| 28|#define FALSE 0 ------------------ 2817| 28| } 2818| 1.52M| ((uint32_t *) array)[count++] = parse_uint32(s, at); 2819| 1.52M| at += s; 2820| 1.52M| rem -= s; 2821| 1.52M| } 2822| 1.17k| break; 2823| | 2824| 5.66k| case PROTOBUF_C_TYPE_SINT64: ------------------ | Branch (2824:2): [True: 5.66k, False: 30.0k] ------------------ 2825| 1.40M| while (rem > 0) { ------------------ | Branch (2825:10): [True: 1.40M, False: 5.64k] ------------------ 2826| 1.40M| unsigned s = scan_varint(rem, at); 2827| 1.40M| if (s == 0) { ------------------ | Branch (2827:8): [True: 22, False: 1.40M] ------------------ 2828| 22| PROTOBUF_C_UNPACK_ERROR("bad packed-repeated sint64 value"); 2829| 22| return FALSE; ------------------ | | 54| 22|#define FALSE 0 ------------------ 2830| 22| } 2831| 1.40M| ((int64_t *) array)[count++] = unzigzag64(parse_uint64(s, at)); 2832| 1.40M| at += s; 2833| 1.40M| rem -= s; 2834| 1.40M| } 2835| 5.64k| break; 2836| 5.64k| case PROTOBUF_C_TYPE_INT64: ------------------ | Branch (2836:2): [True: 803, False: 34.9k] ------------------ 2837| 4.80k| case PROTOBUF_C_TYPE_UINT64: ------------------ | Branch (2837:2): [True: 4.00k, False: 31.7k] ------------------ 2838| 1.71M| while (rem > 0) { ------------------ | Branch (2838:10): [True: 1.71M, False: 4.77k] ------------------ 2839| 1.71M| unsigned s = scan_varint(rem, at); 2840| 1.71M| if (s == 0) { ------------------ | Branch (2840:8): [True: 28, False: 1.71M] ------------------ 2841| 28| PROTOBUF_C_UNPACK_ERROR("bad packed-repeated int64/uint64 value"); 2842| 28| return FALSE; ------------------ | | 54| 28|#define FALSE 0 ------------------ 2843| 28| } 2844| 1.71M| ((int64_t *) array)[count++] = parse_uint64(s, at); 2845| 1.71M| at += s; 2846| 1.71M| rem -= s; 2847| 1.71M| } 2848| 4.77k| break; 2849| 4.77k| case PROTOBUF_C_TYPE_BOOL: ------------------ | Branch (2849:2): [True: 4.43k, False: 31.2k] ------------------ 2850| 340k| while (rem > 0) { ------------------ | Branch (2850:10): [True: 336k, False: 4.42k] ------------------ 2851| 336k| unsigned s = scan_varint(rem, at); 2852| 336k| if (s == 0) { ------------------ | Branch (2852:8): [True: 17, False: 336k] ------------------ 2853| 17| PROTOBUF_C_UNPACK_ERROR("bad packed-repeated boolean value"); 2854| 17| return FALSE; ------------------ | | 54| 17|#define FALSE 0 ------------------ 2855| 17| } 2856| 336k| ((protobuf_c_boolean *) array)[count++] = parse_boolean(s, at); 2857| 336k| at += s; 2858| 336k| rem -= s; 2859| 336k| } 2860| 4.42k| break; 2861| 4.42k| default: ------------------ | Branch (2861:2): [True: 0, False: 35.7k] ------------------ 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| 35.7k| } 2864| 23.1k| *p_n += count; 2865| 23.1k| return TRUE; ------------------ | | 53| 23.1k|#define TRUE 1 ------------------ 2866| | 2867| 0|#if !defined(WORDS_BIGENDIAN) 2868| 12.4k|no_unpacking_needed: 2869| 12.4k| memcpy(array, at, count * siz); 2870| 12.4k| *p_n += count; 2871| 12.4k| return TRUE; ------------------ | | 53| 12.4k|#define TRUE 1 ------------------ 2872| 35.7k|#endif 2873| 35.7k|} protobuf-c.c:scan_varint: 2731| 8.55M|{ 2732| 8.55M| unsigned i; 2733| 8.55M| if (len > 10) ------------------ | Branch (2733:6): [True: 8.45M, False: 94.6k] ------------------ 2734| 8.45M| len = 10; 2735| 9.12M| for (i = 0; i < len; i++) ------------------ | Branch (2735:14): [True: 9.12M, False: 146] ------------------ 2736| 9.12M| if ((data[i] & 0x80) == 0) ------------------ | Branch (2736:7): [True: 8.55M, False: 571k] ------------------ 2737| 8.55M| break; 2738| 8.55M| if (i == len) ------------------ | Branch (2738:6): [True: 146, False: 8.55M] ------------------ 2739| 146| return 0; 2740| 8.55M| return i + 1; 2741| 8.55M|} protobuf-c.c:parse_repeated_member: 2714| 3.81M|{ 2715| 3.81M| const ProtobufCFieldDescriptor *field = scanned_member->field; 2716| 3.81M| size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset); ------------------ | | 116| 3.81M| ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) | | ------------------ | | | | 98| 3.81M| ((void *) ((uint8_t *) (struct_p) + (struct_offset))) | | ------------------ ------------------ 2717| 3.81M| size_t siz = sizeof_elt_in_repeated_array(field->type); 2718| 3.81M| char *array = *(char **) member; 2719| | 2720| 3.81M| if (!parse_required_member(scanned_member, array + siz * (*p_n), ------------------ | Branch (2720:6): [True: 303, False: 3.81M] ------------------ 2721| 3.81M| allocator, FALSE)) ------------------ | | 54| 3.81M|#define FALSE 0 ------------------ 2722| 303| { 2723| 303| return FALSE; ------------------ | | 54| 303|#define FALSE 0 ------------------ 2724| 303| } 2725| 3.81M| *p_n += 1; 2726| 3.81M| return TRUE; ------------------ | | 53| 3.81M|#define TRUE 1 ------------------ 2727| 3.81M|} foo__sub_mess__sub_sub_mess__init: 12| 17.5k|{ 13| | static const Foo__SubMess__SubSubMess init_value = FOO__SUB_MESS__SUB_SUB_MESS__INIT; ------------------ | | 126| 17.5k| { PROTOBUF_C_MESSAGE_INIT (&foo__sub_mess__sub_sub_mess__descriptor) \ | | ------------------ | | | | 1000| 17.5k|#define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL } | | ------------------ | | 127| 17.5k| , 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| 17.5k| *message = init_value; 15| 17.5k|} foo__sub_mess__init: 18| 76.1k|{ 19| | static const Foo__SubMess init_value = FOO__SUB_MESS__INIT; ------------------ | | 144| 76.1k| { PROTOBUF_C_MESSAGE_INIT (&foo__sub_mess__descriptor) \ | | ------------------ | | | | 1000| 76.1k|#define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL } | | ------------------ | | 145| 76.1k| , 0, 0, 0, 0, 0, 0,NULL, NULL, NULL } ------------------ 20| 76.1k| *message = init_value; 21| 76.1k|} foo__test_mess__init: 423| 2.09k|{ 424| | static const Foo__TestMess init_value = FOO__TEST_MESS__INIT; ------------------ | | 269| 2.09k| { PROTOBUF_C_MESSAGE_INIT (&foo__test_mess__descriptor) \ | | ------------------ | | | | 1000| 2.09k|#define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL } | | ------------------ | | 270| 2.09k| , 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.09k| *message = init_value; 426| 2.09k|} LLVMFuzzerTestOneInput: 23| 2.09k|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.09k| ProtobufCMessage *msg = protobuf_c_message_unpack( 31| 2.09k| &foo__test_mess__descriptor, NULL, size, data); 32| 2.09k| if (msg != NULL) { ------------------ | Branch (32:9): [True: 1.28k, False: 809] ------------------ 33| 1.28k| protobuf_c_message_free_unpacked(msg, NULL); 34| 1.28k| } 35| | 36| 2.09k| return 0; 37| 2.09k|}