Skip to content

Commit

Permalink
Build: compiler warning/error fixes for multiple platforms (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxwolf authored Aug 4, 2016
2 parents a9da131 + 6d998c7 commit 011612e
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Implementation of JOSE for C/C++
### Libraries ###

* OpenSSL >= 1.0.1h (or its API equivalent)
* Jansson >= 2.6
* Jansson >= 2.3

## Getting Started ##

Expand Down
2 changes: 1 addition & 1 deletion cjose.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Name: cjose
URL: https://github.com/cisco/cjose
Description: JOSE implementation for C
Version: @VERSION@
Requires: jansson >= 2.6, libcrypto >= 1.0.1
Requires: jansson >= 2.3, libcrypto >= 1.0.1
Cflags: -I${includedir}
Libs: -L${libdir} -lcjose
10 changes: 5 additions & 5 deletions src/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const char *CJOSE_HDR_KID = "kid";
cjose_header_t *cjose_header_new(
cjose_err *err)
{
cjose_header_t *retval = json_object();
cjose_header_t *retval = (cjose_header_t *)json_object();
if (NULL == retval)
{
CJOSE_ERROR(err, CJOSE_ERR_NO_MEMORY);
Expand All @@ -61,7 +61,7 @@ cjose_header_t *cjose_header_retain(
{
if (NULL != header)
{
header = json_incref(header);
header = (cjose_header_t *)json_incref((json_t *)header);
}
return header;
}
Expand All @@ -72,7 +72,7 @@ void cjose_header_release(
{
if (NULL != header)
{
json_decref(header);
json_decref((json_t *)header);
}
}

Expand All @@ -98,7 +98,7 @@ bool cjose_header_set(
}

json_object_set(
header, attr, value_obj);
(json_t *)header, attr, value_obj);

json_decref(value_obj);

Expand All @@ -118,7 +118,7 @@ const char *cjose_header_get(
return NULL;
}

json_t *value_obj = json_object_get(header, attr);
json_t *value_obj = json_object_get((json_t *)header, attr);
if (NULL == value_obj)
{
return NULL;
Expand Down
12 changes: 6 additions & 6 deletions src/jwe.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ static bool _cjose_jwe_build_hdr(
cjose_err *err)
{
// save header object as part of the JWE (and incr. refcount)
jwe->hdr = header;
jwe->hdr = (json_t *)header;
json_incref(jwe->hdr);

// serialize the header
char *hdr_str = json_dumps(header, JSON_ENCODE_ANY | JSON_PRESERVE_ORDER);
char *hdr_str = json_dumps(jwe->hdr, JSON_ENCODE_ANY | JSON_PRESERVE_ORDER);
if (NULL == hdr_str)
{
CJOSE_ERROR(err, CJOSE_ERR_NO_MEMORY);
Expand Down Expand Up @@ -175,7 +175,7 @@ static bool _cjose_jwe_validate_hdr(
cjose_err *err)
{
// make sure we have an alg header
json_t *alg_obj = json_object_get(header, CJOSE_HDR_ALG);
json_t *alg_obj = json_object_get((json_t *)header, CJOSE_HDR_ALG);
if (NULL == alg_obj)
{
CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
Expand All @@ -184,7 +184,7 @@ static bool _cjose_jwe_validate_hdr(
const char *alg = json_string_value(alg_obj);

// make sure we have an enc header
json_t *enc_obj = json_object_get(header, CJOSE_HDR_ENC);
json_t *enc_obj = json_object_get((json_t *)header, CJOSE_HDR_ENC);
if (NULL == enc_obj)
{
CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
Expand Down Expand Up @@ -1381,7 +1381,7 @@ cjose_jwe_t *cjose_jwe_import(
}

// validate the JSON header
if (!_cjose_jwe_validate_hdr(jwe, jwe->hdr, err))
if (!_cjose_jwe_validate_hdr(jwe, (cjose_header_t *)jwe->hdr, err))
{
CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
cjose_jwe_release(jwe);
Expand Down Expand Up @@ -1433,5 +1433,5 @@ cjose_header_t *cjose_jwe_get_protected(cjose_jwe_t *jwe)
{
return NULL;
}
return jwe->hdr;
return (cjose_header_t *)jwe->hdr;
}
4 changes: 2 additions & 2 deletions src/jws.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static bool _cjose_jws_build_hdr(
cjose_err *err)
{
// save header object as part of the JWS (and incr. refcount)
jws->hdr = header;
jws->hdr = (json_t *)header;
json_incref(jws->hdr);

// base64url encode the header
Expand Down Expand Up @@ -1202,5 +1202,5 @@ cjose_header_t *cjose_jws_get_protected(
return NULL;
}

return jws->hdr;
return (cjose_header_t *)jws->hdr;
}
6 changes: 3 additions & 3 deletions test/check_jwe.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ static void _self_encrypt_self_decrypt_with_key(

// confirm plain2 == plain1
ck_assert(json_equal(
cjose_jwe_get_protected(jwe1),
cjose_jwe_get_protected(jwe2)));
(json_t *)cjose_jwe_get_protected(jwe1),
(json_t *)cjose_jwe_get_protected(jwe2)));
ck_assert_msg(
plain2_len == strlen(plain1),
"length of decrypted plaintext does not match length of original, "
Expand Down Expand Up @@ -458,7 +458,7 @@ START_TEST(test_cjose_jwe_import_export_compare)
err.message, err.file, err.function, err.line);

// re-export the jwe object
const char *cser = cjose_jwe_export(jwe, &err);
char *cser = cjose_jwe_export(jwe, &err);
ck_assert_msg(NULL != cser,
"re-export of imported JWE failed: "
"%s, file: %s, function: %s, line: %ld",
Expand Down
16 changes: 8 additions & 8 deletions test/check_jwk.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ START_TEST(test_cjose_jwk_to_json_oct)
jwk = cjose_jwk_create_oct_spec(k, klen, &err);
cjose_get_dealloc()(k);

const char *json;
char *json;
json = cjose_jwk_to_json(jwk, false, &err);
ck_assert(NULL != json);
ck_assert_str_eq("{\"kty\":\"oct\"}", json);
Expand Down Expand Up @@ -478,7 +478,7 @@ START_TEST(test_cjose_jwk_to_json_ec)
cjose_get_dealloc()(spec.x);
cjose_get_dealloc()(spec.y);

const char *json;
char *json;
json = cjose_jwk_to_json(jwk, false, &err);
ck_assert(NULL != json);
ck_assert_str_eq(
Expand Down Expand Up @@ -533,7 +533,7 @@ START_TEST(test_cjose_jwk_to_json_rsa)
cjose_get_dealloc()(spec.dq);
cjose_get_dealloc()(spec.qi);

const char *json;
char *json;
json = cjose_jwk_to_json(jwk, false, &err);
ck_assert(NULL != json);
ck_assert_str_eq(RSA_PUBLIC_JSON, json);
Expand Down Expand Up @@ -673,7 +673,7 @@ START_TEST(test_cjose_jwk_import_valid)
ck_assert(NULL != left_json);

// get json representation of "after"
const char *jwk_str = cjose_jwk_to_json(jwk, true, &err);
char *jwk_str = cjose_jwk_to_json(jwk, true, &err);
json_t *right_json = json_loads(jwk_str, 0, NULL);
ck_assert(NULL != right_json);

Expand Down Expand Up @@ -852,7 +852,7 @@ START_TEST(test_cjose_jwk_import_no_zero_termination)
ck_assert(NULL != left_json);

// get json representation of "after"
const char *jwk_str = cjose_jwk_to_json(jwk, true, &err);
char *jwk_str = cjose_jwk_to_json(jwk, true, &err);
json_t *right_json = json_loads(jwk_str, 0, NULL);
ck_assert(NULL != right_json);

Expand Down Expand Up @@ -896,7 +896,7 @@ START_TEST(test_cjose_jwk_import_with_base64url_padding)
ck_assert(NULL != left_json);

// get json representation of "actual" (i.e. reserialized original)
const char *jwk_str = cjose_jwk_to_json(jwk, true, &err);
char *jwk_str = cjose_jwk_to_json(jwk, true, &err);
json_t *right_json = json_loads(jwk_str, 0, NULL);
ck_assert(NULL != right_json);

Expand Down Expand Up @@ -941,7 +941,7 @@ START_TEST(test_cjose_jwk_EC_import_with_priv_export_with_pub)
ck_assert(NULL != left_json);

// get json representation of "actual" (i.e. reserialized original)
const char *jwk_str = cjose_jwk_to_json(jwk, true, &err);
char *jwk_str = cjose_jwk_to_json(jwk, true, &err);
json_t *right_json = json_loads(jwk_str, 0, NULL);
ck_assert(NULL != right_json);

Expand Down Expand Up @@ -1058,7 +1058,7 @@ START_TEST(test_cjose_jwk_get_and_set_kid)
ck_assert(sizeof(JWK_BEFORE) == sizeof(JWK_AFTER));

const char *kid = NULL;
const char *json = NULL;
char *json = NULL;
for (int i = 0; JWK_BEFORE[i] != NULL; ++i)
{
// import the before state
Expand Down
8 changes: 4 additions & 4 deletions test/check_jws.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static void _self_sign_self_verify(
ck_assert(hdr == cjose_jws_get_protected(jws1));

// get the compact serialization of JWS
char *compact = NULL;
const char *compact = NULL;
ck_assert_msg(
cjose_jws_export(jws1, &compact, err),
"cjose_jws_export failed: "
Expand Down Expand Up @@ -111,8 +111,8 @@ static void _self_sign_self_verify(

// confirm equal headers
ck_assert(json_equal(
cjose_jws_get_protected(jws1),
cjose_jws_get_protected(jws2)));
(json_t *)cjose_jws_get_protected(jws1),
(json_t *)cjose_jws_get_protected(jws2)));

// confirm plain2 == plain1
ck_assert_msg(
Expand Down Expand Up @@ -929,7 +929,7 @@ START_TEST(test_cjose_jws_none)
err.message, err.file, err.function, err.line);

// try to sign the unsecured JWS
ck_assert_msg(!cjose_jws_sign(jwk, jws->hdr, PLAINTEXT, strlen(PLAINTEXT), &err),
ck_assert_msg(!cjose_jws_sign(jwk, (cjose_header_t *)jws->hdr, PLAINTEXT, strlen(PLAINTEXT), &err),
"cjose_jws_sign succeeded for unsecured JWT");

cjose_jws_release(jws);
Expand Down

0 comments on commit 011612e

Please sign in to comment.