forked from Imagelibrary/lwip
Apply patch #10406: simplify sign extension
This commit is contained in:
@@ -463,14 +463,8 @@ snmp_asn1_dec_s32t(struct snmp_pbuf_stream *pbuf_stream, u16_t len, s32_t *value
|
|||||||
if ((len > 0) && (len < 5)) {
|
if ((len > 0) && (len < 5)) {
|
||||||
PBUF_OP_EXEC(snmp_pbuf_stream_read(pbuf_stream, &data));
|
PBUF_OP_EXEC(snmp_pbuf_stream_read(pbuf_stream, &data));
|
||||||
|
|
||||||
if (data & 0x80) {
|
/* sign extension */
|
||||||
/* negative, start from -1 */
|
*value = (s8_t)data;
|
||||||
*value = -1;
|
|
||||||
*value = (*value << 8) | data;
|
|
||||||
} else {
|
|
||||||
/* positive, start from 0 */
|
|
||||||
*value = data;
|
|
||||||
}
|
|
||||||
len--;
|
len--;
|
||||||
/* shift in the remaining value */
|
/* shift in the remaining value */
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user