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';
|
||||
}
|
||||
|
||||
// possible to use 16 bit identifier, can't be defined yet from outside
|
||||
bool use_16_bit_identifier = false;
|
||||
uint8_t udhlen = 0;
|
||||
// Length can be update after we have created PDU, store position for later use.
|
||||
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
|
||||
// user data header length in chars
|
||||
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
|
||||
pdu[x++] = '5';
|
||||
}
|
||||
// Information element identifier
|
||||
pdu[x++] = '0';
|
||||
if (use_16_bit_identifier) {
|
||||
pdu[x++] = '8';
|
||||
} else {
|
||||
pdu[x++] = '0';
|
||||
}
|
||||
// Information element data length
|
||||
pdu[x++] = '0';
|
||||
if (use_16_bit_identifier) {
|
||||
pdu[x++] = '4';
|
||||
} else {
|
||||
pdu[x++] = '3';
|
||||
}
|
||||
// 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);
|
||||
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?
|
||||
int_to_hex_str(msg_parts, pdu+x);
|
||||
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)
|
||||
{
|
||||
// +CMGR: <stat>,[<alpha>],<length><CR><LF><pdu>
|
||||
int index = -1;
|
||||
int index;
|
||||
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.
|
||||
int status = -1;
|
||||
int msg_len = 0;
|
||||
int status;
|
||||
int msg_len;
|
||||
index = 0;
|
||||
int pduSize = 0;
|
||||
int pduSize;
|
||||
|
||||
for (int i = 0; i < sms->parts; i++) {
|
||||
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;
|
||||
char tmp;
|
||||
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
// convert to 7bit gsm first
|
||||
char* gsm_str = (char*)malloc(len);
|
||||
if (!gsm_str) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue