Commit 16abdfa1 authored by Raphael Defosseux's avatar Raphael Defosseux
Browse files

CPPCHECK: fix a few errors


Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@openairinterface.org>
parent b89aa8a2
......@@ -163,7 +163,8 @@ int balloc(bstring b, int olen) {
#if defined(BSTRLIB_TEST_CANARY)
if (len > b->slen + 1) {
memchr(b->data + b->slen + 1, 'X', len - (b->slen + 1));
if ((memchr(b->data + b->slen + 1, 'X', len - (b->slen + 1))) == NULL)
return BSTR_ERR;
}
#endif
}
......@@ -217,7 +218,8 @@ bstring bfromcstr(const char* str) {
b = (bstring) bstr__alloc(sizeof(struct tagbstring));
if (NULL == b) return NULL;
b->slen = (int) j;
if (NULL == (b->data = (unsigned char*) bstr__alloc(b->mlen = i))) {
b->data = (unsigned char*) bstr__alloc(b->mlen = i);
if (b->data == NULL) {
bstr__free(b);
return NULL;
}
......@@ -1587,7 +1589,8 @@ int binsertblk(
/* Aliasing case */
if (((size_t)((unsigned char*) blk + len)) >= ((size_t) b->data) &&
((size_t) blk) < ((size_t)(b->data + b->mlen))) {
if (NULL == (aux = (unsigned char*) bstr__alloc(len))) return BSTR_ERR;
aux = (unsigned char*) bstr__alloc(len);
if (aux == NULL) return BSTR_ERR;
bstr__memcpy(aux, blk, len);
}
......@@ -2475,8 +2478,10 @@ bstring bjoinblk(const struct bstrList* bl, const void* blk, int len) {
* NULL is returned, otherwise a bstring with the correct result is returned.
*/
bstring bjoin(const struct bstrList* bl, const_bstring sep) {
if (sep == NULL) return NULL;
if (sep != NULL && (sep->slen < 0 || sep->data == NULL)) return NULL;
if (sep == NULL)
return NULL;
else if (sep->slen < 0 || sep->data == NULL)
return NULL;
return bjoinblk(bl, sep->data, sep->slen);
}
......
......@@ -113,7 +113,8 @@ CBString::CBString(char c, int len) {
CBString::CBString(char c) {
mlen = 2;
slen = 1;
if (NULL == (data = (unsigned char*) bstr__alloc(mlen))) {
data = (unsigned char*) bstr__alloc(mlen);
if (data == NULL) {
mlen = slen = 0;
bstringThrow("Failure in (char) constructor");
} else {
......@@ -125,7 +126,8 @@ CBString::CBString(char c) {
CBString::CBString(unsigned char c) {
mlen = 2;
slen = 1;
if (NULL == (data = (unsigned char*) bstr__alloc(mlen))) {
data = (unsigned char*) bstr__alloc(mlen);
if (data == NULL) {
mlen = slen = 0;
bstringThrow("Failure in (char) constructor");
} else {
......@@ -141,7 +143,8 @@ CBString::CBString(const char* s) {
bstringThrow("Failure in (char *) constructor, string too large") slen =
(int) sslen;
mlen = slen + 1;
if (NULL != (data = (unsigned char*) bstr__alloc(mlen))) {
data = (unsigned char*) bstr__alloc(mlen);
if (data != NULL) {
bstr__memcpy(data, s, mlen);
return;
}
......@@ -158,7 +161,8 @@ CBString::CBString(int len, const char* s) {
(int) sslen;
mlen = slen + 1;
if (mlen < len) mlen = len;
if (NULL != (data = (unsigned char*) bstr__alloc(mlen))) {
data = (unsigned char*) bstr__alloc(mlen);
if (data != NULL) {
bstr__memcpy(data, s, slen + 1);
return;
}
......@@ -1519,7 +1523,6 @@ void CBStringList::splitstr(const CBString& b, const CBString& s) {
static int streamSplitCb(void* parm, int ofs, const_bstring entry) {
CBStringList* r = (CBStringList*) parm;
ofs = ofs;
r->push_back(CBString(*entry));
return 0;
}
......
......@@ -58,7 +58,7 @@ int decode_authentication_response(
return decoded_result;
else {
decoded += decoded_result;
printf("decoded(%d)\n", decoded);
printf("decoded(%u)\n", decoded);
authentication_response->presence |=
AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT;
}
......
......@@ -32,7 +32,7 @@ int decode_registration_request(
uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0;
printf("decode_registration_request len:%d\n", len);
printf("decode_registration_request len:%u\n", len);
if ((decoded_result = decode__5gs_registration_type(
&registration_request->_5gsregistrationtype, 0, buffer + decoded,
......
......@@ -111,7 +111,7 @@ asn_dec_rval_t NativeEnumerated_decode_uper(
if (!native) ASN__DECODE_FAILED;
}
ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
if (td->name) ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
if (ct->flags & APC_EXTENSIBLE) {
int inext = per_get_few_bits(pd, 1);
......@@ -171,7 +171,7 @@ asn_enc_rval_t NativeEnumerated_encode_uper(
else
ASN__ENCODE_FAILED; /* Mandatory! */
ASN_DEBUG("Encoding %s as NativeEnumerated", td->name);
if (td->name) ASN_DEBUG("Encoding %s as NativeEnumerated", td->name);
er.encoded = 0;
......@@ -307,7 +307,7 @@ asn_enc_rval_t NativeEnumerated_encode_aper(
else
ASN__ENCODE_FAILED; /* Mandatory! */
ASN_DEBUG("Encoding %s as NativeEnumerated", td->name);
if (td->name) ASN_DEBUG("Encoding %s as NativeEnumerated", td->name);
er.encoded = 0;
......
......@@ -263,7 +263,7 @@ asn_dec_rval_t NativeInteger_decode_uper(
void* tmpintptr = &tmpint;
(void) opt_codec_ctx;
ASN_DEBUG("Decoding NativeInteger %s (UPER)", td->name);
if (td->name) ASN_DEBUG("Decoding NativeInteger %s (UPER)", td->name);
if (!native) {
native = (long*) (*sptr = CALLOC(1, sizeof(*native)));
......@@ -298,7 +298,8 @@ asn_enc_rval_t NativeInteger_encode_uper(
native = *(const long*) sptr;
ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native);
if (td->name)
ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native);
memset(&tmpint, 0, sizeof(tmpint));
if ((specs && specs->field_unsigned) ? asn_ulong2INTEGER(&tmpint, native) :
......@@ -320,7 +321,7 @@ asn_dec_rval_t NativeInteger_decode_aper(
void* tmpintptr = &tmpint;
(void) opt_codec_ctx;
ASN_DEBUG("Decoding NativeInteger %s (APER)", td->name);
if (td->name) ASN_DEBUG("Decoding NativeInteger %s (APER)", td->name);
if (!native) {
native = (long*) (*sptr = CALLOC(1, sizeof(*native)));
......@@ -355,7 +356,8 @@ asn_enc_rval_t NativeInteger_encode_aper(
native = *(const long*) sptr;
ASN_DEBUG("Encoding NativeInteger %s %ld (APER)", td->name, native);
if (td->name)
ASN_DEBUG("Encoding NativeInteger %s %ld (APER)", td->name, native);
memset(&tmpint, 0, sizeof(tmpint));
if ((specs && specs->field_unsigned) ?
......
......@@ -207,7 +207,10 @@ static enum xer_pbd_rval OBJECT_IDENTIFIER__xer_body_decode(
if (!arcs) return XPBD_SYSTEM_FAILURE;
ret = OBJECT_IDENTIFIER_parse_arcs(
(const char*) chunk_buf, chunk_size, arcs, num_arcs, &endptr);
if (ret != num_arcs) return XPBD_SYSTEM_FAILURE; /* assert?.. */
if (ret != num_arcs) {
FREEMEM(arcs);
return XPBD_SYSTEM_FAILURE; /* assert?.. */
}
}
/*
......
......@@ -1139,7 +1139,7 @@ asn_enc_rval_t CHOICE_encode_aper(
return elm->type->op->aper_encoder(
elm->type, elm->encoding_constraints.per_constraints, memb_ptr, po);
} else {
} else if (ct) {
asn_enc_rval_t rval;
if (specs->ext_start == -1) ASN__ENCODE_FAILED;
if (aper_put_nsnnwn(po, ct->range_bits, present - specs->ext_start))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment