[Title] fix the Dereference before null check, Operands don't affect result
[platform/adaptation/emulator/vmodem-daemon-emulator.git] / vmodem / at / at_tx_sat.c
1 /*
2  *  telephony-emulator
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: 
7  * Sooyoung Ha <yoosah.ha@samsung.com>
8  * Sungmin Ha <sungmin82.ha@samsung.com>
9  * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
10  * 
11  * This library is free software; you can redistribute it and/or modify it under
12  * the terms of the GNU Lesser General Public License as published by the
13  * Free Software Foundation; either version 2.1 of the License, or (at your option)
14  * any later version.
15  * 
16  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
17  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19  * License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this library; if not, write to the Free Software Foundation, Inc., 51
23  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24  *
25  * Contributors:
26  * - S-Core Co., Ltd
27  * 
28  */
29
30 /////////////////////////////////////////////////////////////////////
31 // at_tx_sat.c
32
33 #include <stdlib.h>
34 #include <string.h>
35 #include <assert.h>
36
37 #include "at_send.h"
38 #include "at_tx_func.h"
39
40 static const int max_proactive_command_length = 0x100;
41
42 int TxSAT_ATGetProactiveCommand(GSM_SatProactiveCmd const* pProactiveCmd)
43 {
44         unsigned char data[2 + max_proactive_command_length];
45         int n = 0;
46
47         TRACE(MSGL_VGSM_INFO, "\n");
48
49         // this is always passed because (pProactiveCmd->length&0xff00) is always 0, so comment out
50         //assert(!(pProactiveCmd->length&0xff00));
51
52         data[n++] = (pProactiveCmd->length)&0xff;
53         // this is always 0 because (pProactiveCmd->length >> 8) is 0, so fix like below
54         //data[n++] = (pProactiveCmd->length >> 8)&0xff;
55         data[n++] = 0;
56
57         memcpy(&data[n], pProactiveCmd->cmd, pProactiveCmd->length);
58         n += pProactiveCmd->length;
59
60         assert(n <= sizeof data);
61
62         TRACE(MSGL_VGSM_INFO, "\n");
63         return 0;
64 //      return at_msg_send(ACK_SEQ_RESPONSE, data, n);
65 }
66