OK here is the asm for a non-zeroed ipaddr
0805088c <netconf_get_ip_config_value>:
static ip_addr_t netconf_get_ip_config_value(
char *name, // In Config option name to read
char *default_value, // In The default value of the option as a string
char *filename, // In The filename of the config file
int number
) {
805088c: b5f0 push {r4, r5, r6, r7, lr}
805088e: b087 sub sp, #28
8050890: af02 add r7, sp, #8
8050892: 460e mov r6, r1
ip_addr_t ipaddr;
unsigned int a, b, c, d;
char value[number];
8050894: 1dd9 adds r1, r3, #7
8050896: f021 0107 bic.w r1, r1, #7
805089a: ebad 0d01 sub.w sp, sp, r1
805089e: 466d mov r5, sp
//char value[20];
file_get_config_value_default(name, value, default_value, filename, sizeof(value));
80508a0: b29b uxth r3, r3
80508a2: f845 3b08 str.w r3, [r5], #8
80508a6: 4613 mov r3, r2
80508a8: 4632 mov r2, r6
80508aa: 4629 mov r1, r5
80508ac: f7fc f95e bl 804cb6c <file_get_config_value_default>
if (sscanf(value, "%u.%u.%u.%u", &a, &b, &c, &d) == 4) {
80508b0: 9701 str r7, [sp, #4]
80508b2: 1d3b adds r3, r7, #4
80508b4: 9300 str r3, [sp, #0]
80508b6: f107 0308 add.w r3, r7, #8
80508ba: f107 020c add.w r2, r7, #12
80508be: 4924 ldr r1, [pc, #144] ; (8050950 <netconf_get_ip_config_value+0xc4>)
80508c0: 4628 mov r0, r5
80508c2: f008 f943 bl 8058b4c <sscanf>
80508c6: 2804 cmp r0, #4
80508c8: d11b bne.n 8050902 <netconf_get_ip_config_value+0x76>
IP4_ADDR(&ipaddr, a, b, c, d);
80508ca: 68bb ldr r3, [r7, #8]
80508cc: 041b lsls r3, r3, #16
80508ce: f403 037f and.w r3, r3, #16711680 ; 0xff0000
80508d2: 68fa ldr r2, [r7, #12]
80508d4: ea43 6302 orr.w r3, r3, r2, lsl #24
80508d8: 687a ldr r2, [r7, #4]
80508da: 0212 lsls r2, r2, #8
80508dc: b292 uxth r2, r2
80508de: 4313 orrs r3, r2
80508e0: 783a ldrb r2, [r7, #0]
80508e2: 4313 orrs r3, r2
80508e4: 021c lsls r4, r3, #8
80508e6: f404 047f and.w r4, r4, #16711680 ; 0xff0000
80508ea: ea44 6402 orr.w r4, r4, r2, lsl #24
80508ee: 0a1a lsrs r2, r3, #8
80508f0: f402 427f and.w r2, r2, #65280 ; 0xff00
80508f4: 4314 orrs r4, r2
80508f6: ea44 6413 orr.w r4, r4, r3, lsr #24
IP4_ADDR(&ipaddr, a, b, c, d);
}
}
return ipaddr;
}
and here is the asm for the zeroed ipaddr:
0805088c <netconf_get_ip_config_value>:
static ip_addr_t netconf_get_ip_config_value(
char *name, // In Config option name to read
char *default_value, // In The default value of the option as a string
char *filename, // In The filename of the config file
int number
) {
805088c: b5f0 push {r4, r5, r6, r7, lr}
805088e: b087 sub sp, #28
8050890: af02 add r7, sp, #8
8050892: 460e mov r6, r1
ip_addr_t ipaddr = {0};
unsigned int a, b, c, d;
char value[number];
8050894: 1dd9 adds r1, r3, #7
8050896: f021 0107 bic.w r1, r1, #7
805089a: ebad 0d01 sub.w sp, sp, r1
805089e: 466d mov r5, sp
//char value[20];
file_get_config_value_default(name, value, default_value, filename, sizeof(value));
80508a0: b29b uxth r3, r3
80508a2: f845 3b08 str.w r3, [r5], #8
80508a6: 4613 mov r3, r2
80508a8: 4632 mov r2, r6
80508aa: 4629 mov r1, r5
80508ac: f7fc f95e bl 804cb6c <file_get_config_value_default>
if (sscanf(value, "%u.%u.%u.%u", &a, &b, &c, &d) == 4) {
80508b0: 9701 str r7, [sp, #4]
80508b2: 1d3b adds r3, r7, #4
80508b4: 9300 str r3, [sp, #0]
80508b6: f107 0308 add.w r3, r7, #8
80508ba: f107 020c add.w r2, r7, #12
80508be: 4924 ldr r1, [pc, #144] ; (8050950 <netconf_get_ip_config_value+0xc4>)
80508c0: 4628 mov r0, r5
80508c2: f008 f943 bl 8058b4c <sscanf>
80508c6: 2804 cmp r0, #4
80508c8: d11b bne.n 8050902 <netconf_get_ip_config_value+0x76>
IP4_ADDR(&ipaddr, a, b, c, d);
80508ca: 68bb ldr r3, [r7, #8]
80508cc: 041b lsls r3, r3, #16
80508ce: f403 037f and.w r3, r3, #16711680 ; 0xff0000
80508d2: 68fa ldr r2, [r7, #12]
80508d4: ea43 6302 orr.w r3, r3, r2, lsl #24
80508d8: 687a ldr r2, [r7, #4]
80508da: 0212 lsls r2, r2, #8
80508dc: b292 uxth r2, r2
80508de: 4313 orrs r3, r2
80508e0: 783a ldrb r2, [r7, #0]
80508e2: 4313 orrs r3, r2
80508e4: 021c lsls r4, r3, #8
80508e6: f404 047f and.w r4, r4, #16711680 ; 0xff0000
80508ea: ea44 6402 orr.w r4, r4, r2, lsl #24
80508ee: 0a1a lsrs r2, r3, #8
80508f0: f402 427f and.w r2, r2, #65280 ; 0xff00
80508f4: 4314 orrs r4, r2
80508f6: ea44 6413 orr.w r4, r4, r3, lsr #24
IP4_ADDR(&ipaddr, a, b, c, d);
}
}
return ipaddr;
}
A comparison shows no change.
Above is with -Og. With -O1 I do see a difference. Here are the two cases, same order as above
0804f40c <netconf_get_ip_config_value>:
static ip_addr_t netconf_get_ip_config_value(
char *name, // In Config option name to read
char *default_value, // In The default value of the option as a string
char *filename, // In The filename of the config file
int number
) {
804f40c: b5f0 push {r4, r5, r6, r7, lr}
804f40e: b087 sub sp, #28
804f410: af02 add r7, sp, #8
804f412: 460e mov r6, r1
ip_addr_t ipaddr;
unsigned int a, b, c, d;
char value[number];
804f414: 1dd9 adds r1, r3, #7
804f416: f021 0107 bic.w r1, r1, #7
804f41a: ebad 0d01 sub.w sp, sp, r1
804f41e: 466d mov r5, sp
//char value[20];
file_get_config_value_default(name, value, default_value, filename, sizeof(value));
804f420: b29b uxth r3, r3
804f422: f845 3b08 str.w r3, [r5], #8
804f426: 4613 mov r3, r2
804f428: 4632 mov r2, r6
804f42a: 4629 mov r1, r5
804f42c: f7fc fa04 bl 804b838 <file_get_config_value_default>
if (sscanf(value, "%u.%u.%u.%u", &a, &b, &c, &d) == 4) {
804f430: 9701 str r7, [sp, #4]
804f432: 1d3b adds r3, r7, #4
804f434: 9300 str r3, [sp, #0]
804f436: f107 0308 add.w r3, r7, #8
804f43a: f107 020c add.w r2, r7, #12
804f43e: 491a ldr r1, [pc, #104] ; (804f4a8 <netconf_get_ip_config_value+0x9c>)
804f440: 4628 mov r0, r5
804f442: f008 f819 bl 8057478 <sscanf>
804f446: 2804 cmp r0, #4
804f448: d111 bne.n 804f46e <netconf_get_ip_config_value+0x62>
IP4_ADDR(&ipaddr, a, b, c, d);
804f44a: 7839 ldrb r1, [r7, #0]
804f44c: 68bb ldr r3, [r7, #8]
804f44e: 021b lsls r3, r3, #8
804f450: 687a ldr r2, [r7, #4]
804f452: 0212 lsls r2, r2, #8
804f454: b292 uxth r2, r2
804f456: 7b3c ldrb r4, [r7, #12]
804f458: ea44 6401 orr.w r4, r4, r1, lsl #24
804f45c: ea44 2402 orr.w r4, r4, r2, lsl #8
804f460: f403 437f and.w r3, r3, #65280 ; 0xff00
804f464: 431c orrs r4, r3
IP4_ADDR(&ipaddr, a, b, c, d);
}
}
return ipaddr;
}
0804f40c <netconf_get_ip_config_value>:
static ip_addr_t netconf_get_ip_config_value(
char *name, // In Config option name to read
char *default_value, // In The default value of the option as a string
char *filename, // In The filename of the config file
int number
) {
804f40c: b5b0 push {r4, r5, r7, lr}
804f40e: b086 sub sp, #24
804f410: af02 add r7, sp, #8
804f412: 460d mov r5, r1
ip_addr_t ipaddr = {0};
unsigned int a, b, c, d;
char value[number];
804f414: 1dd9 adds r1, r3, #7
804f416: f021 0107 bic.w r1, r1, #7
804f41a: ebad 0d01 sub.w sp, sp, r1
804f41e: 466c mov r4, sp
//char value[20];
file_get_config_value_default(name, value, default_value, filename, sizeof(value));
804f420: b29b uxth r3, r3
804f422: f844 3b08 str.w r3, [r4], #8
804f426: 4613 mov r3, r2
804f428: 462a mov r2, r5
804f42a: 4621 mov r1, r4
804f42c: f7fc fa04 bl 804b838 <file_get_config_value_default>
if (sscanf(value, "%u.%u.%u.%u", &a, &b, &c, &d) == 4) {
804f430: 9701 str r7, [sp, #4]
804f432: 1d3b adds r3, r7, #4
804f434: 9300 str r3, [sp, #0]
804f436: f107 0308 add.w r3, r7, #8
804f43a: f107 020c add.w r2, r7, #12
804f43e: 491a ldr r1, [pc, #104] ; (804f4a8 <netconf_get_ip_config_value+0x9c>)
804f440: 4620 mov r0, r4
804f442: f008 f819 bl 8057478 <sscanf>
804f446: 2804 cmp r0, #4
804f448: d110 bne.n 804f46c <netconf_get_ip_config_value+0x60>
IP4_ADDR(&ipaddr, a, b, c, d);
804f44a: 7839 ldrb r1, [r7, #0]
804f44c: 68bb ldr r3, [r7, #8]
804f44e: 021b lsls r3, r3, #8
804f450: 687a ldr r2, [r7, #4]
804f452: 0212 lsls r2, r2, #8
804f454: b292 uxth r2, r2
804f456: 7b38 ldrb r0, [r7, #12]
804f458: ea40 6001 orr.w r0, r0, r1, lsl #24
804f45c: ea40 2002 orr.w r0, r0, r2, lsl #8
804f460: f403 437f and.w r3, r3, #65280 ; 0xff00
804f464: 4318 orrs r0, r3
IP4_ADDR(&ipaddr, a, b, c, d);
}
}
return ipaddr;
}
The code looks similar but registers are used differently. The difference starts with
sub sp, #28
sub sp, #24
and as posted before, the non-zeroing version with -O1 produces that warning.