Commit 052e1ce7 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix-format-warnings' into 'develop'

Fix format warnings

See merge request oai/cn5g/oai-cn5g-smf!74
parents e996535c 0c301ce4
......@@ -31,6 +31,7 @@ source $THIS_SCRIPT_PATH/build_helper
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_fb_folly_from_source(){
echo "Starting to install folly"
if [ $1 -eq 0 ]; then
OPTION=""
read -p "Do you want to install FaceBook folly (github)? <y/N> " prompt
......@@ -141,6 +142,6 @@ install_fb_folly_from_source(){
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd
fi
echo_success "End of folly installation"
echo_success "folly installation complete"
return 0
}
......@@ -37,6 +37,7 @@ source $THIS_SCRIPT_PATH/build_helper.fb_folly
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_fmt() {
echo "Starting to install fmt"
if [ $1 -eq 0 ]; then
read -p "Do you want to install open-source formatting library for C++ ? <y/N> " prompt
OPTION=""
......@@ -65,6 +66,7 @@ install_fmt() {
cd /tmp
rm -rf /tmp/fmt*
fi
echo "fmt installation complete"
return 0
}
......@@ -72,6 +74,7 @@ install_fmt() {
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_spdlog_from_git() {
echo "Starting to install spdlog"
if [ $1 -eq 0 ]; then
read -p "Do you want to install spdlog ? <y/N> " prompt
OPTION=""
......@@ -104,6 +107,7 @@ install_spdlog_from_git() {
sed -i '/#define SPDLOG_ENABLE_SYSLOG/s/^\/\///g' include/spdlog/tweakme.h
popd
fi
echo "spdlog installation complete"
return 0
}
......@@ -111,6 +115,7 @@ install_spdlog_from_git() {
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_pistache_from_git() {
echo "Starting to install pistache"
if [ $1 -eq 0 ]; then
read -p "Do you want to install Pistache ? <y/N> " prompt
OPTION="-y"
......@@ -153,6 +158,7 @@ install_pistache_from_git() {
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd
fi
echo "pistache installation complete"
return 0
}
......@@ -160,6 +166,7 @@ install_pistache_from_git() {
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_nlohmann_from_git() {
echo "Starting to install Nlohmann Json"
if [ $1 -eq 0 ]; then
read -p "Do you want to install Nlohmann Json ? <y/N> " prompt
OPTION=""
......@@ -198,6 +205,7 @@ install_nlohmann_from_git() {
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd
fi
echo "Nlohmann Json installation complete"
return 0
}
......@@ -205,6 +213,7 @@ install_nlohmann_from_git() {
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_nghttp2_from_git() {
echo "Starting to install nghttp2"
if [ $1 -eq 0 ]; then
read -p "Do you want to install nghttp2 ? <y/N> " prompt
OPTION=""
......@@ -286,6 +295,7 @@ install_nghttp2_from_git() {
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd
fi
echo "nghttp2 installation complete"
return 0
}
......@@ -410,6 +420,7 @@ check_install_smf_deps() {
echo "Install distro libs"
$SUDO $INSTALLER install $OPTION $PACKAGE_LIST
ret=$?;[[ $ret -ne 0 ]] && return $ret
echo "distro libs installation complete"
# Use fmt lib included in spdlog
#install_fmt $1
......@@ -525,6 +536,7 @@ check_install_smf_min_deps() {
echo "Install networking tools"
$SUDO $INSTALLER install $OPTION $PACKAGE_LIST
ret=$?;[[ $ret -ne 0 ]] && return $ret
echo "networking tools installation complete"
return 0
}
......
......@@ -479,8 +479,6 @@ class HtmlReport():
section_end_pattern = 'build_smf --clean --Verbose --build-type Release --jobs'
section_status = False
package_install = False
fmt_build_start = False
fmt_build_status = False
folly_build_start = False
folly_build_status = False
spdlog_build_start = False
......@@ -489,6 +487,8 @@ class HtmlReport():
pistache_build_status = False
json_build_start = False
json_build_status = False
nghttp2_build_start = False
nghttp2_build_status = False
base_image = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
for line in logfile:
......@@ -505,35 +505,39 @@ class HtmlReport():
result = re.search('SMF deps installation successful', line)
if result is not None:
status = True
result = re.search('Install fmt from source', line)
result = re.search('distro libs installation complete', line)
if result is not None:
package_install = True
fmt_build_start = True
result = re.search('Installing: /usr/local/lib/pkgconfig/fmt.pc', line)
if result is not None:
fmt_build_status = True
result = re.search('Cloning into \'folly\'', line)
result = re.search('Starting to install folly', line)
if result is not None:
folly_build_start = True
result = re.search('Installing: /usr/local/lib/libfollybenchmark.a', line)
if result is not None:
result = re.search('folly installation complete', line)
if result is not None and folly_build_start:
folly_build_status = True
result = re.search('Install spdlog from', line)
result = re.search('Starting to install spdlog', line)
if result is not None:
spdlog_build_start = True
result = re.search('Install Pistache from', line)
if result is not None:
result = re.search('spdlog installation complete', line)
if result is not None and spdlog_build_start:
spdlog_build_status = True
pistache_build_start = True
result = re.search('Installing: /usr/local/lib/libpistache.a', line)
result = re.search('Starting to install pistache', line)
if result is not None:
pistache_build_start = True
result = re.search('pistache installation complete', line)
if result is not None and pistache_build_start:
pistache_build_status = True
result = re.search('Install Nlohmann Json', line)
result = re.search('Starting to install Nlohmann Json', line)
if result is not None:
json_build_start = True
result = re.search('Nlohmann Json installation complete', line)
if result is not None and json_build_start:
json_build_status = True
result = re.search('Installing: /usr/local/lib/cmake/nlohmann_json/nlohmann_jsonTargets.cmake', line)
result = re.search('Starting to install nghttp2', line)
if result is not None:
json_build_status = True
nghttp2_build_start = True
result = re.search('nghttp2 installation complete', line)
if result is not None and nghttp2_build_start:
nghttp2_build_status = True
logfile.close()
if base_image:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>'
......@@ -552,23 +556,17 @@ class HtmlReport():
else:
cell_msg += ' ** Packages Installation: KO\n'
if base_image:
cell_msg += ' ** fmt Installation: N/A\n'
elif fmt_build_status:
cell_msg += ' ** fmt Installation: OK\n'
cell_msg += ' ** spdlog Installation: N/A\n'
elif spdlog_build_status:
cell_msg += ' ** spdlog Installation: OK\n'
else:
cell_msg += ' ** fmt Installation: KO\n'
cell_msg += ' ** spdlog Installation: KO\n'
if base_image:
cell_msg += ' ** folly Installation: N/A\n'
elif folly_build_status:
cell_msg += ' ** folly Installation: OK\n'
else:
cell_msg += ' ** folly Installation: KO\n'
if base_image:
cell_msg += ' ** spdlog Installation: N/A\n'
elif spdlog_build_status:
cell_msg += ' ** spdlog Installation: OK\n'
else:
cell_msg += ' ** spdlog Installation: KO\n'
if base_image:
cell_msg += ' ** pistache Installation: N/A\n'
elif pistache_build_status:
......@@ -581,6 +579,12 @@ class HtmlReport():
cell_msg += ' ** Nlohmann Json Installation: OK\n'
else:
cell_msg += ' ** Nlohmann Json Installation: KO\n'
if base_image:
cell_msg += ' ** nghttp2 Installation: N/A\n'
elif nghttp2_build_status:
cell_msg += ' ** nghttp2 Installation: OK\n'
else:
cell_msg += ' ** nghttp2 Installation: KO\n'
cell_msg += '</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
......
......@@ -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,
......
......@@ -1288,6 +1288,34 @@ int asn_INTEGER2ulong(const INTEGER_t* iptr, unsigned long* l) {
}
}
int asn_INTEGER2longlong(const INTEGER_t* iptr, long long* l) {
intmax_t v;
if (asn_INTEGER2imax(iptr, &v) == 0) {
if (v < LLONG_MIN || v > LLONG_MAX) {
errno = ERANGE;
return -1;
}
*l = v;
return 0;
} else {
return -1;
}
}
int asn_INTEGER2ulonglong(const INTEGER_t* iptr, unsigned long long* l) {
uintmax_t v;
if (asn_INTEGER2umax(iptr, &v) == 0) {
if (v > ULLONG_MAX) {
errno = ERANGE;
return -1;
}
*l = v;
return 0;
} else {
return -1;
}
}
int asn_long2INTEGER(INTEGER_t* st, long value) {
return asn_imax2INTEGER(st, value);
}
......
......@@ -73,6 +73,8 @@ int asn_umax2INTEGER(INTEGER_t* i, uintmax_t l);
*/
int asn_INTEGER2long(const INTEGER_t* i, long* l);
int asn_INTEGER2ulong(const INTEGER_t* i, unsigned long* l);
int asn_INTEGER2longlong(const INTEGER_t* i, long long* l);
int asn_INTEGER2ulonglong(const INTEGER_t* i, unsigned long long* l);
int asn_long2INTEGER(INTEGER_t* i, long l);
int asn_ulong2INTEGER(INTEGER_t* i, unsigned long l);
int asn_int642INTEGER(INTEGER_t* i, int64_t l);
......
......@@ -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))
......@@ -1149,6 +1149,8 @@ asn_enc_rval_t CHOICE_encode_aper(
ASN__ENCODE_FAILED;
rval.encoded = 0;
ASN__ENCODED_OK(rval);
} else {
ASN__ENCODE_FAILED;
}
}
......
......@@ -47,8 +47,8 @@ typedef struct Ngap_AssociatedQosFlowItem {
} Ngap_AssociatedQosFlowItem_t;
/* Implementation */
/* extern asn_TYPE_descriptor_t asn_DEF_Ngap_qosFlowMappingIndication_3; //
* (Use -fall-defs-global to expose) */
/* extern asn_TYPE_descriptor_t asn_DEF_Ngap_qosFlowMappingIndication_3;
* // (Use -fall-defs-global to expose) */
extern asn_TYPE_descriptor_t asn_DEF_Ngap_AssociatedQosFlowItem;
extern asn_SEQUENCE_specifics_t asn_SPC_Ngap_AssociatedQosFlowItem_specs_1;
extern asn_TYPE_member_t asn_MBR_Ngap_AssociatedQosFlowItem_1[3];
......
......@@ -65,7 +65,7 @@ static int memb_Ngap_usageCountUL_constraint_1(
const asn_TYPE_descriptor_t* td, const void* sptr,
asn_app_constraint_failed_f* ctfailcb, void* app_key) {
const INTEGER_t* st = (const INTEGER_t*) sptr;
long value;
unsigned long long value;
if (!sptr) {
ASN__CTFAIL(
......@@ -74,14 +74,14 @@ static int memb_Ngap_usageCountUL_constraint_1(
return -1;
}
if (asn_INTEGER2long(st, &value)) {
if (asn_INTEGER2ulonglong(st, &value)) {
ASN__CTFAIL(
app_key, td, sptr, "%s: value too large (%s:%d)", td->name, __FILE__,
__LINE__);
return -1;
}
if ((value >= 0 && value <= 18446744073709551615)) {
if ((value >= 0 && value <= ULLONG_MAX)) {
/* Constraint check succeeded */
return 0;
} else {
......@@ -96,7 +96,7 @@ static int memb_Ngap_usageCountDL_constraint_1(
const asn_TYPE_descriptor_t* td, const void* sptr,
asn_app_constraint_failed_f* ctfailcb, void* app_key) {
const INTEGER_t* st = (const INTEGER_t*) sptr;
long value;
unsigned long long value;
if (!sptr) {
ASN__CTFAIL(
......@@ -105,14 +105,14 @@ static int memb_Ngap_usageCountDL_constraint_1(
return -1;
}
if (asn_INTEGER2long(st, &value)) {
if (asn_INTEGER2ulonglong(st, &value)) {
ASN__CTFAIL(
app_key, td, sptr, "%s: value too large (%s:%d)", td->name, __FILE__,
__LINE__);
return -1;
}
if ((value >= 0 && value <= 18446744073709551615)) {
if ((value >= 0 && value <= ULLONG_MAX)) {
/* Constraint check succeeded */
return 0;
} else {
......@@ -146,7 +146,7 @@ static asn_oer_constraints_t asn_OER_memb_Ngap_usageCountUL_constr_4
static asn_per_constraints_t asn_PER_memb_Ngap_usageCountUL_constr_4
CC_NOTUSED = {
{APC_CONSTRAINED, 64, -1, 0,
18446744073709551615} /* (0..18446744073709551615) */,
ULLONG_MAX} /* (0..18446744073709551615) */,
{APC_UNCONSTRAINED, -1, -1, 0, 0},
0,
0 /* No PER value map */
......@@ -156,7 +156,7 @@ static asn_oer_constraints_t asn_OER_memb_Ngap_usageCountDL_constr_5
static asn_per_constraints_t asn_PER_memb_Ngap_usageCountDL_constr_5
CC_NOTUSED = {
{APC_CONSTRAINED, 64, -1, 0,
18446744073709551615} /* (0..18446744073709551615) */,
ULLONG_MAX} /* (0..18446744073709551615) */,
{APC_UNCONSTRAINED, -1, -1, 0, 0},
0,
0 /* No PER value map */
......
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