Skip to content

Commit 8fcfbe1

Browse files
authored
Merge pull request #12079 from AnttiKauppila/coverity_fixes
Coverity fixes
2 parents 8c673ba + 11b1df0 commit 8fcfbe1

File tree

4 files changed

+20
-29
lines changed

4 files changed

+20
-29
lines changed

features/cellular/framework/AT/ATHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ nsapi_error_t ATHandler::at_cmd_str(const char *cmd, const char *cmd_chr, char *
13391339

13401340
cmd_stop();
13411341

1342-
if (cmd && strlen(cmd) > 0) {
1342+
if (strlen(cmd) > 0) {
13431343
memcpy(_cmd_buffer, cmd, strlen(cmd));
13441344
_cmd_buffer[strlen(cmd)] = ':';
13451345
_cmd_buffer[strlen(cmd) + 1] = '\0';

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
8080
};
8181
#endif
8282

83-
UBLOX_AT::UBLOX_AT(FileHandle *fh) : AT_CellularDevice(fh)
83+
UBLOX_AT::UBLOX_AT(FileHandle *fh) : AT_CellularDevice(fh), ubx_context(0)
8484
{
8585
set_cellular_properties(cellular_properties);
8686
}
@@ -117,38 +117,36 @@ nsapi_error_t UBLOX_AT::init()
117117
_at->lock();
118118
_at->flush();
119119
_at->at_cmd_discard("", "");
120-
121-
nsapi_error_t err = NSAPI_ERROR_OK;
120+
int value = -1;
122121

123122
#ifdef UBX_MDM_SARA_G3XX
124-
err = _at->at_cmd_discard("+CFUN", "=0");
125-
126-
if (err == NSAPI_ERROR_OK) {
127-
_at->at_cmd_discard("E0", ""); // echo off
128-
_at->at_cmd_discard("+CMEE", "=1"); // verbose responses
129-
config_authentication_parameters();
130-
err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality
131-
}
123+
value = 0;
132124
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_R41XM)
133-
err = _at->at_cmd_discard("+CFUN", "=4");
125+
value = 4;
126+
#else
127+
_at->unlock();
128+
return NSAPI_ERROR_UNSUPPORTED;
129+
#endif
130+
131+
nsapi_error_t err = _at->at_cmd_discard("+CFUN", "=", "%d", value);
132+
134133
if (err == NSAPI_ERROR_OK) {
135134
_at->at_cmd_discard("E0", ""); // echo off
136135
_at->at_cmd_discard("+CMEE", "=1"); // verbose responses
137136
config_authentication_parameters();
138137
err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality
139138
}
140-
#else
141-
_at->unlock();
142-
return NSAPI_ERROR_UNSUPPORTED;
143-
#endif
144-
145139
return _at->unlock_return_error();
146140
}
147141

148142
nsapi_error_t UBLOX_AT::config_authentication_parameters()
149143
{
150144
char *config = NULL;
151145
nsapi_error_t err;
146+
const char *apn;
147+
const char *uname;
148+
const char *pwd;
149+
CellularContext::AuthenticationType auth = CellularContext::NOAUTH;
152150
char imsi[MAX_IMSI_LENGTH + 1];
153151

154152
if (ubx_context->get_apn() == NULL) {
@@ -162,9 +160,10 @@ nsapi_error_t UBLOX_AT::config_authentication_parameters()
162160
apn = ubx_context->get_apn();
163161
pwd = ubx_context->get_pwd();
164162
uname = ubx_context->get_uname();
165-
auth = ubx_context->get_auth();
166163

167-
auth = (*uname && *pwd) ? auth : CellularContext::NOAUTH;
164+
if (*uname && *pwd) {
165+
auth = ubx_context->get_auth();
166+
}
168167
err = set_authentication_parameters(apn, uname, pwd, auth);
169168

170169
return err;

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ class UBLOX_AT : public AT_CellularDevice {
5555
*/
5656
static const int MAX_IMSI_LENGTH = 15;
5757

58-
const char *apn;
59-
const char *uname;
60-
const char *pwd;
61-
62-
/** The type of authentication to use.
63-
*/
64-
CellularContext::AuthenticationType auth;
65-
6658
nsapi_error_t config_authentication_parameters();
6759

6860
nsapi_error_t set_authentication_parameters(const char *apn, const char *username, const char *password, CellularContext::AuthenticationType auth);

features/frameworks/mbed-client-cli/source/ns_cmdline.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2082,7 +2082,7 @@ bool cmd_parameter_timestamp(int argc, char *argv[], const char *key, int64_t *v
20822082
char *token;
20832083
token = strtok(argv[i + 1], splitValue);
20842084
if (token) {
2085-
*value = strtoul(token, 0, 10) << 16;
2085+
*value = (int64_t)strtoul(token, 0, 10) << 16;
20862086
}
20872087
token = strtok(NULL, splitValue);
20882088
if (token) {

0 commit comments

Comments
 (0)