mirror of https://github.com/ARMmbed/mbed-os.git
Fixed coverity warnings for AT_CellularSMS.cpp
parent
89843246ac
commit
f6be35c0f2
|
|
@ -352,8 +352,6 @@ char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message,
|
||||||
pdu[x++] = '0';
|
pdu[x++] = '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
// possible to use 16 bit identifier, can't be defined yet from outside
|
|
||||||
bool use_16_bit_identifier = false;
|
|
||||||
uint8_t udhlen = 0;
|
uint8_t udhlen = 0;
|
||||||
// Length can be update after we have created PDU, store position for later use.
|
// Length can be update after we have created PDU, store position for later use.
|
||||||
int lengthPos = x;
|
int lengthPos = x;
|
||||||
|
|
@ -363,34 +361,17 @@ char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message,
|
||||||
if (msg_parts > 1) { // concatenated, must use UDH
|
if (msg_parts > 1) { // concatenated, must use UDH
|
||||||
// user data header length in chars
|
// user data header length in chars
|
||||||
pdu[x++] = '0';
|
pdu[x++] = '0';
|
||||||
if (use_16_bit_identifier) {
|
|
||||||
udhlen = 7; // udh length in chars (6) + udhl length in chars
|
|
||||||
pdu[x++] = '6';
|
|
||||||
} else {
|
|
||||||
udhlen = 6; // udh length in chars (5) + udhl length in chars
|
udhlen = 6; // udh length in chars (5) + udhl length in chars
|
||||||
pdu[x++] = '5';
|
pdu[x++] = '5';
|
||||||
}
|
|
||||||
// Information element identifier
|
// Information element identifier
|
||||||
pdu[x++] = '0';
|
pdu[x++] = '0';
|
||||||
if (use_16_bit_identifier) {
|
|
||||||
pdu[x++] = '8';
|
|
||||||
} else {
|
|
||||||
pdu[x++] = '0';
|
pdu[x++] = '0';
|
||||||
}
|
|
||||||
// Information element data length
|
// Information element data length
|
||||||
pdu[x++] = '0';
|
pdu[x++] = '0';
|
||||||
if (use_16_bit_identifier) {
|
|
||||||
pdu[x++] = '4';
|
|
||||||
} else {
|
|
||||||
pdu[x++] = '3';
|
pdu[x++] = '3';
|
||||||
}
|
|
||||||
// A reference number (must be the same for all parts of the same larger messages)
|
// A reference number (must be the same for all parts of the same larger messages)
|
||||||
int_to_hex_str(_sms_message_ref_number&0xFF, pdu+x);
|
int_to_hex_str(_sms_message_ref_number&0xFF, pdu+x);
|
||||||
x +=2;
|
x +=2;
|
||||||
if (use_16_bit_identifier) {
|
|
||||||
int_to_hex_str((_sms_message_ref_number>>16)&0xFF, pdu+x);
|
|
||||||
x +=2;
|
|
||||||
}
|
|
||||||
// How many parts does this message have?
|
// How many parts does this message have?
|
||||||
int_to_hex_str(msg_parts, pdu+x);
|
int_to_hex_str(msg_parts, pdu+x);
|
||||||
x +=2;
|
x +=2;
|
||||||
|
|
@ -678,13 +659,13 @@ nsapi_size_or_error_t AT_CellularSMS::read_sms_from_index(int msg_index, char* b
|
||||||
nsapi_size_or_error_t AT_CellularSMS::read_sms(sms_info_t* sms, char* buf, char* phone_num, char* time_stamp)
|
nsapi_size_or_error_t AT_CellularSMS::read_sms(sms_info_t* sms, char* buf, char* phone_num, char* time_stamp)
|
||||||
{
|
{
|
||||||
// +CMGR: <stat>,[<alpha>],<length><CR><LF><pdu>
|
// +CMGR: <stat>,[<alpha>],<length><CR><LF><pdu>
|
||||||
int index = -1;
|
int index;
|
||||||
if (sms->parts == sms->parts_added) {
|
if (sms->parts == sms->parts_added) {
|
||||||
char *pdu; // we need a temp buffer as payload is hexencoded ---> can't use buf as it might be enough for message but not hexenconded pdu.
|
char *pdu; // we need a temp buffer as payload is hexencoded ---> can't use buf as it might be enough for message but not hexenconded pdu.
|
||||||
int status = -1;
|
int status;
|
||||||
int msg_len = 0;
|
int msg_len;
|
||||||
index = 0;
|
index = 0;
|
||||||
int pduSize = 0;
|
int pduSize;
|
||||||
|
|
||||||
for (int i = 0; i < sms->parts; i++) {
|
for (int i = 0; i < sms->parts; i++) {
|
||||||
wait_ms(_sim_wait_time);
|
wait_ms(_sim_wait_time);
|
||||||
|
|
@ -1212,6 +1193,9 @@ uint16_t AT_CellularSMS::pack_7_bit_gsm_and_hex(const char* str, uint16_t len, c
|
||||||
uint8_t shift;
|
uint8_t shift;
|
||||||
char tmp;
|
char tmp;
|
||||||
|
|
||||||
|
if (len == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
// convert to 7bit gsm first
|
// convert to 7bit gsm first
|
||||||
char* gsm_str = (char*)malloc(len);
|
char* gsm_str = (char*)malloc(len);
|
||||||
if (!gsm_str) {
|
if (!gsm_str) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue