FreeCalypso > hg > fc-magnetite
view cdg211/cdginc/p_uart.val @ 516:1ed9de6c90bd
src/g23m-gsm/sms/sms_for.c: bogus malloc removed
The new error handling code that was not present in TCS211 blob version
contains a malloc call that is bogus for 3 reasons:
1) The memory allocation in question is not needed in the first place;
2) libc malloc is used instead of one of the firmware's proper ways;
3) The memory allocation is made inside a function and then never freed,
i.e., a memory leak.
This bug was caught in gcc-built FreeCalypso fw projects (Citrine
and Selenite) because our gcc environment does not allow any use of
libc malloc (any reference to malloc produces a link failure),
but this code from TCS3.2 is wrong even for Magnetite: if this code
path is executed repeatedly over a long time, the many small allocations
made by this malloc call without a subsequent free will eventually
exhaust the malloc heap provided by the TMS470 environment, malloc will
start returning NULL, and the bogus code will treat it as an error.
Because the memory allocation in question is not needed at all,
the fix entails simply removing it.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 22 Jul 2018 06:04:49 +0000 |
parents | 56abf6cf8a0b |
children |
line wrap: on
line source
/* +--------------------------------------------------------------------------+ | PROJECT : PROTOCOL STACK | | FILE : p_uart.val | | SOURCE : "__out__\g23m_dfile\prim\uart.pdf" | | LastModified : "2002-03-11" | | IdAndVersion : "8441.117.99.014" | | SrcFileTime : "Tue Nov 30 11:21:48 2004" | | Generated by CCDGEN_2.5.5 on Fri Jun 08 13:59:16 2007 | | !!DO NOT MODIFY!!DO NOT MODIFY!!DO NOT MODIFY!! | +--------------------------------------------------------------------------+ */ /* PRAGMAS * PREFIX : NONE * COMPATIBILITY_DEFINES : NO (require PREFIX) * ALWAYS_ENUM_IN_VAL_FILE: NO * ENABLE_GROUP: NO * CAPITALIZE_TYPENAME: NO */ #ifndef P_UART_VAL #define P_UART_VAL #define CDG_ENTER__P_UART_VAL #define CDG_ENTER__FILENAME _P_UART_VAL #define CDG_ENTER__P_UART_VAL__FILE_TYPE CDGINC #define CDG_ENTER__P_UART_VAL__LAST_MODIFIED _2002_03_11 #define CDG_ENTER__P_UART_VAL__ID_AND_VERSION _8441_117_99_014 #define CDG_ENTER__P_UART_VAL__SRC_FILE_TIME _Tue_Nov_30_11_21_48_2004 #include "CDG_ENTER.h" #undef CDG_ENTER__P_UART_VAL #undef CDG_ENTER__FILENAME /* * Value constants for VAL_esc_valid */ #define UART_IO_ESC_UNDEF (0x0) /* values for escape sequence detection remain unchanged */ #define UART_IO_ESC_VALID (0x1) /* values for escape sequence detection are valid */ /* * Value constants for VAL_xoff */ #define UART_IO_XOFF_DEFAULT (0x13) /* default value for XOff character */ /* * Value constants for VAL_xon */ #define UART_IO_XON_DEFAULT (0x11) /* default value for XOn character */ /* * Value constants for VAL_parity */ #define UART_IO_PA_UNDEF (0xff) /* parity remain unchanged */ #define UART_IO_PA_NONE (0x0) /* no parity and no space */ #define UART_IO_PA_EVEN (0x1) /* even parity */ #define UART_IO_PA_ODD (0x2) /* odd parity */ #define UART_IO_PA_SPACE (0x3) /* no parity but space */ /* * Value constants for VAL_flow_tx */ #define UART_IO_FC_TX_UNDEF (0xff) /* TX flow control mode remain unchanged */ #define UART_IO_FC_TX_NONE (0x0) /* no TX flow control */ #define UART_IO_FC_TX_RTS (0x1) /* RTS/CTS flow control */ #define UART_IO_FC_TX_XOFF (0x2) /* XON/XOFF flow control */ /* * Value constants for VAL_esc_char */ #define UART_IO_ESC_CHAR_DEFAULT (0x2b) /* default value for escape character ('+') */ /* * Value constants for VAL_flow_rx */ #define UART_IO_FC_RX_UNDEF (0xff) /* RX flow control mode remain unchanged */ #define UART_IO_FC_RX_NONE (0x0) /* no RX flow control */ #define UART_IO_FC_RX_RTS (0x1) /* RTS/CTS flow control */ #define UART_IO_FC_RX_XOFF (0x2) /* XON/XOFF flow control */ /* * Value constants for VAL_nsb */ #define UART_IO_SB_UNDEF (0xff) /* stop bits remain unchanged */ #define UART_IO_SB_1 (0x1) /* one stop bit */ #define UART_IO_SB_2 (0x2) /* two stop bits */ /* * Value constants for VAL_speed */ #define UART_IO_SPEED_UNDEF (0xff) /* baud rate remain unchanged */ #define UART_IO_SPEED_AUTO (0x0) /* auto detection of baud rate */ #define UART_IO_SPEED_75 (0x1) /* baud rate of 75 bits per second */ #define UART_IO_SPEED_150 (0x2) /* baud rate of 150 bits per second */ #define UART_IO_SPEED_300 (0x3) /* baud rate of 300 bits per second */ #define UART_IO_SPEED_600 (0x4) /* baud rate of 600 bits per second */ #define UART_IO_SPEED_1200 (0x5) /* baud rate of 1200 bits per second */ #define UART_IO_SPEED_2400 (0x6) /* baud rate of 2400 bits per second */ #define UART_IO_SPEED_4800 (0x7) /* baud rate of 4800 bits per second */ #define UART_IO_SPEED_7200 (0x8) /* baud rate of 7200 bits per second */ #define UART_IO_SPEED_9600 (0x9) /* baud rate of 9600 bits per second */ #define UART_IO_SPEED_14400 (0xa) /* baud rate of 14400 bits per second */ #define UART_IO_SPEED_19200 (0xb) /* baud rate of 19200 bits per second */ #define UART_IO_SPEED_28800 (0xc) /* baud rate of 28800 bits per second */ #define UART_IO_SPEED_33900 (0xd) /* baud rate of 33900 bits per second */ #define UART_IO_SPEED_38400 (0xe) /* baud rate of 38400 bits per second */ #define UART_IO_SPEED_57600 (0xf) /* baud rate of 57600 bits per second */ #define UART_IO_SPEED_115200 (0x10) /* baud rate of 115200 bits per second */ #define UART_IO_SPEED_203125 (0x11) /* baud rate of 203125 bits per second */ #define UART_IO_SPEED_406250 (0x12) /* baud rate of 406250 bits per second */ #define UART_IO_SPEED_812500 (0x13) /* baud rate of 812500 bits per second */ /* * Value constants for VAL_esc_gp */ #define UART_IO_ESC_GP_DEFAULT (0x3e8) /* default value for guard period (1000 ms) */ #define UART_IO_ESC_OFF (0x0) /* no escape sequence detection */ /* * Value constants for VAL_xoff_valid */ #define UART_IO_XOFF_UNDEF (0x0) /* XOff character remain unchanged */ #define UART_IO_XOFF_VALID (0x1) /* XOff character valid */ /* * Value constants for VAL_xon_valid */ #define UART_IO_XON_UNDEF (0x0) /* XOn character remain unchanged */ #define UART_IO_XON_VALID (0x1) /* XOn character valid */ /* * Value constants for VAL_bpc */ #define UART_IO_BPC_UNDEF (0xff) /* bits per character remain unchanged */ #define UART_IO_BPC_7 (0x7) /* 7 bits per character */ #define UART_IO_BPC_8 (0x8) /* 8 bits per character */ /* * Value constants for VAL_dti_conn */ #define UART_CONNECT_DTI (0x0) /* Connect DTI to UART */ #define UART_DISCONNECT_DTI (0x1) /* Disconnect DTI from UART */ /* * Value constants for VAL_line_state */ #define UART_LINE_ON (0x0) /* activate line */ #define UART_LINE_OFF (0x1) /* deactivate line */ /* * Value constants for VAL_detection */ #define UART_ESC_DETECTION_OFF (0x0) /* turn off escape sequence detection */ #define UART_ESC_DETECTION_ON (0x1) /* turn on escape sequence detection */ /* * Value constants for VAL_cause */ #define UART_DETECT_ESC (0x1) /* escape sequence detected */ #define UART_DETECT_DTR (0x2) /* DTR line of serial link drops */ /* * Value constants for VAL_error */ #define UART_ERROR_NO_CHANNEL (0x8) /* can not open VSI communication channel */ #define UART_ERROR_MUX_ESTABLISH_FAIL (0x9) /* establishment of multiplexer operation fails */ #define UART_ERROR_MUX_NO_RESPONSE (0xa) /* no response from TE multiplexer */ /* * Value constants for VAL_mode */ #define UART_MUX_MODE_BASIC (0x0) /* basic option */ #define UART_MUX_MODE_ADVANCED (0x1) /* advanced option */ /* * Value constants for VAL_frame_type */ #define UART_MUX_FRAME_UIH (0x0) /* UIH frames used only */ #define UART_MUX_FRAME_UI (0x1) /* UI frames used only */ #define UART_MUX_FRAME_I (0x2) /* I frames used only */ #define UART_MUX_FRAME_DEFAULT (0x0) /* default value */ /* * Value constants for VAL_n1 */ #define UART_MUX_N1_BASIC_DEFAULT (0x1f) /* default value for the basic option */ #define UART_MUX_N1_ADVANCED_DEFAULT (0x40) /* default value for the advanced option */ /* * Value constants for VAL_t1 */ #define UART_MUX_T1_DEFAULT (0xa) /* default value (100 ms) */ /* * Value constants for VAL_n2 */ #define UART_MUX_N2_DEFAULT (0x3) /* default value */ /* * Value constants for VAL_t2 */ #define UART_MUX_T2_DEFAULT (0x1e) /* default value (300 ms) */ /* * Value constants for VAL_t3 */ #define UART_MUX_T3_DEFAULT (0xa) /* default value (10 seconds) */ /* * Value constants for VAL_convergence */ #define UART_MUX_CONVERGENCE_UOS (0x1) /* unstructed octet stream */ #define UART_MUX_CONVERGENCE_UOSV24 (0x2) /* unstructed octet stream with transmission of V.24 signal states */ #define UART_MUX_CONVERGENCE_UFD (0x3) /* uninterruptible framed data */ #define UART_MUX_CONVERGENCE_IFD (0x4) /* interruptible framed data */ #define UART_MUX_CONVERGENCE_DEFAULT (0x1) /* default value */ /* * Value constants for VAL_service */ #define UART_MUX_SERVICE_AT (0x0) /* AT command mode */ #define UART_MUX_SERVICE_DATA (0x1) /* data service */ #define UART_MUX_SERVICE_VOICE_0621 (0x2) /* voice service (coded - GSM 06.21) */ #define UART_MUX_SERVICE_VOICE_PCM64U (0x3) /* voice service (coded - PCM 64 kbits/s U-law) */ #define UART_MUX_SERVICE_VOICE_ADPCM (0x4) /* voice service (coded - ADPCM 32 kbits/s) */ #define UART_MUX_SERVICE_VOICE_PCM64A (0x5) /* voice service (coded - PCM 64 kbits/s A-law) */ #define UART_MUX_SERVICE_VOICE_PCM128 (0x6) /* voice service (coded - PCM 128 kbits/s) */ #define UART_MUX_SERVICE_GPRS (0x7) /* GPRS data */ #define UART_MUX_SERVICE_CS (0x8) /* Circuit-Switched data */ #define UART_MUX_SERVICE_TRACE (0x9) /* Trace / Debug output */ #define UART_MUX_SERVICE_DEFAULT (0x0) /* default value */ /* * user defined constants */ #define UART_DLCI_NOT_MULTIPLEXED (0x0) #include "CDG_LEAVE.h" #endif