mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-03 21:14:40 +08:00
Apply patch #10406: simplify sign extension
This commit is contained in:
parent
ffce5ab1c7
commit
8459488006
@ -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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user