Merge pull request #732 from DiracResearch/fix/static_include_dirs

Fix/static include dirs
This commit is contained in:
Eric Hawicz
2021-11-11 23:52:43 -05:00
committed by GitHub
4 changed files with 14 additions and 9 deletions

View File

@@ -472,6 +472,11 @@ if (BUILD_STATIC_LIBS AND BUILD_SHARED_LIBS)
${JSON_C_SOURCES} ${JSON_C_SOURCES}
${JSON_C_HEADERS} ${JSON_C_HEADERS}
) )
target_include_directories(${PROJECT_NAME}-static
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
)
# rename the static library # rename the static library
if (NOT MSVC) if (NOT MSVC)

View File

@@ -1058,8 +1058,7 @@ static int json_object_double_to_json_string_format(struct json_object *jso, str
format_drops_decimals = 1; format_drops_decimals = 1;
looks_numeric = /* Looks like *some* kind of number */ looks_numeric = /* Looks like *some* kind of number */
is_plain_digit(buf[0]) || is_plain_digit(buf[0]) || (size > 1 && buf[0] == '-' && is_plain_digit(buf[1]));
(size > 1 && buf[0] == '-' && is_plain_digit(buf[1]));
if (size < (int)sizeof(buf) - 2 && looks_numeric && !p && /* Has no decimal point */ if (size < (int)sizeof(buf) - 2 && looks_numeric && !p && /* Has no decimal point */
strchr(buf, 'e') == NULL && /* Not scientific notation */ strchr(buf, 'e') == NULL && /* Not scientific notation */
@@ -1283,7 +1282,8 @@ static struct json_object *_json_object_new_string(const char *s, const size_t l
return NULL; return NULL;
jso->len = len; jso->len = len;
memcpy(jso->c_string.idata, s, len); memcpy(jso->c_string.idata, s, len);
jso->c_string.idata[len] = '\0'; // Cast below needed for Clang UB sanitizer
((char *)jso->c_string.idata)[len] = '\0';
return &jso->base; return &jso->base;
} }
@@ -1733,8 +1733,8 @@ static int json_object_deep_copy_recursive(struct json_object *src, struct json_
/* This handles the `json_type_null` case */ /* This handles the `json_type_null` case */
if (!iter.val) if (!iter.val)
jso = NULL; jso = NULL;
else if (json_object_deep_copy_recursive(iter.val, src, iter.key, UINT_MAX, &jso, else if (json_object_deep_copy_recursive(iter.val, src, iter.key, UINT_MAX,
shallow_copy) < 0) &jso, shallow_copy) < 0)
{ {
json_object_put(jso); json_object_put(jso);
return -1; return -1;

View File

@@ -486,7 +486,7 @@ static unsigned long lh_char_hash(const void *k)
#endif #endif
} }
return hashlittle((const char *)k, strlen((const char *)k), random_seed); return hashlittle((const char *)k, strlen((const char *)k), (uint32_t)random_seed);
} }
int lh_char_equal(const void *k1, const void *k2) int lh_char_equal(const void *k1, const void *k2)

View File

@@ -329,21 +329,21 @@ int json_c_get_random_seed(void)
#else #else
#ifdef HAVE_GETRANDOM #ifdef HAVE_GETRANDOM
{ {
int seed; int seed = 0;
if (get_getrandom_seed(&seed) == 0) if (get_getrandom_seed(&seed) == 0)
return seed; return seed;
} }
#endif #endif
#if defined HAVE_DEV_RANDOM && HAVE_DEV_RANDOM #if defined HAVE_DEV_RANDOM && HAVE_DEV_RANDOM
{ {
int seed; int seed = 0;
if (get_dev_random_seed(&seed) == 0) if (get_dev_random_seed(&seed) == 0)
return seed; return seed;
} }
#endif #endif
#if defined HAVE_CRYPTGENRANDOM && HAVE_CRYPTGENRANDOM #if defined HAVE_CRYPTGENRANDOM && HAVE_CRYPTGENRANDOM
{ {
int seed; int seed = 0;
if (get_cryptgenrandom_seed(&seed) == 0) if (get_cryptgenrandom_seed(&seed) == 0)
return seed; return seed;
} }