MCPcopy Create free account
hub / github.com/corosync/corosync / icmap_check_value_len

Function icmap_check_value_len

exec/icmap.c:334–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334static int icmap_check_value_len(const void *value, size_t value_len, icmap_value_types_t type)
335{
336
337 if (value_len > ICMAP_MAX_VALUE_LEN) {
338 return (-1);
339 }
340
341 if (type != ICMAP_VALUETYPE_STRING && type != ICMAP_VALUETYPE_BINARY) {
342 if (icmap_get_valuetype_len(type) == value_len) {
343 return (0);
344 } else {
345 return (-1);
346 }
347 }
348
349 if (type == ICMAP_VALUETYPE_STRING) {
350 /*
351 * value_len can be shorter then real string length, but never
352 * longer (+ 1 is because of 0 at the end of string)
353 */
354 if (value_len > strlen((const char *)value) + 1) {
355 return (-1);
356 } else {
357 return (0);
358 }
359 }
360
361 return (0);
362}
363
364static int icmap_item_eq(const struct icmap_item *item, const void *value, size_t value_len, icmap_value_types_t type)
365{

Callers 1

icmap_set_rFunction · 0.85

Calls 1

icmap_get_valuetype_lenFunction · 0.85

Tested by

no test coverage detected