Skip to content

Coverity fixes #12079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/cellular/framework/AT/ATHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ nsapi_error_t ATHandler::at_cmd_str(const char *cmd, const char *cmd_chr, char *

cmd_stop();

if (cmd && strlen(cmd) > 0) {
if (strlen(cmd) > 0) {
memcpy(_cmd_buffer, cmd, strlen(cmd));
_cmd_buffer[strlen(cmd)] = ':';
_cmd_buffer[strlen(cmd) + 1] = '\0';
Expand Down
37 changes: 18 additions & 19 deletions features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
};
#endif

UBLOX_AT::UBLOX_AT(FileHandle *fh) : AT_CellularDevice(fh)
UBLOX_AT::UBLOX_AT(FileHandle *fh) : AT_CellularDevice(fh), ubx_context(0)
{
set_cellular_properties(cellular_properties);
}
Expand Down Expand Up @@ -117,38 +117,36 @@ nsapi_error_t UBLOX_AT::init()
_at->lock();
_at->flush();
_at->at_cmd_discard("", "");

nsapi_error_t err = NSAPI_ERROR_OK;
int value = -1;

#ifdef UBX_MDM_SARA_G3XX
err = _at->at_cmd_discard("+CFUN", "=0");

if (err == NSAPI_ERROR_OK) {
_at->at_cmd_discard("E0", ""); // echo off
_at->at_cmd_discard("+CMEE", "=1"); // verbose responses
config_authentication_parameters();
err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality
}
value = 0;
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_R41XM)
err = _at->at_cmd_discard("+CFUN", "=4");
value = 4;
#else
_at->unlock();
return NSAPI_ERROR_UNSUPPORTED;
#endif

nsapi_error_t err = _at->at_cmd_discard("+CFUN", "=", "%d", value);

if (err == NSAPI_ERROR_OK) {
_at->at_cmd_discard("E0", ""); // echo off
_at->at_cmd_discard("+CMEE", "=1"); // verbose responses
config_authentication_parameters();
err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality
}
#else
_at->unlock();
return NSAPI_ERROR_UNSUPPORTED;
#endif

return _at->unlock_return_error();
}

nsapi_error_t UBLOX_AT::config_authentication_parameters()
{
char *config = NULL;
nsapi_error_t err;
const char *apn;
const char *uname;
const char *pwd;
CellularContext::AuthenticationType auth = CellularContext::NOAUTH;
char imsi[MAX_IMSI_LENGTH + 1];

if (ubx_context->get_apn() == NULL) {
Expand All @@ -162,9 +160,10 @@ nsapi_error_t UBLOX_AT::config_authentication_parameters()
apn = ubx_context->get_apn();
pwd = ubx_context->get_pwd();
uname = ubx_context->get_uname();
auth = ubx_context->get_auth();

auth = (*uname && *pwd) ? auth : CellularContext::NOAUTH;
if (*uname && *pwd) {
auth = ubx_context->get_auth();
}
err = set_authentication_parameters(apn, uname, pwd, auth);

return err;
Expand Down
8 changes: 0 additions & 8 deletions features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ class UBLOX_AT : public AT_CellularDevice {
*/
static const int MAX_IMSI_LENGTH = 15;

const char *apn;
const char *uname;
const char *pwd;

/** The type of authentication to use.
*/
CellularContext::AuthenticationType auth;

nsapi_error_t config_authentication_parameters();

nsapi_error_t set_authentication_parameters(const char *apn, const char *username, const char *password, CellularContext::AuthenticationType auth);
Expand Down
2 changes: 1 addition & 1 deletion features/frameworks/mbed-client-cli/source/ns_cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ bool cmd_parameter_timestamp(int argc, char *argv[], const char *key, int64_t *v
char *token;
token = strtok(argv[i + 1], splitValue);
if (token) {
*value = strtoul(token, 0, 10) << 16;
*value = (int64_t)strtoul(token, 0, 10) << 16;
}
token = strtok(NULL, splitValue);
if (token) {
Expand Down