Skip to content

Commit ebbf015

Browse files
committed
fix printing percentages to be standard compliant
Using \% is glibc extension and does not work in all systems. This changes PrintAndLogEx() to call the underlying function so that percent is not exapanded any more, and we can use the standard %% to express percent character.
1 parent 43cbf8f commit ebbf015

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

client/cmdhw.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static void lookupChipID(uint32_t iChipID, uint32_t mem_used) {
7474
if ( mem_avail > 0 )
7575
mem_left = (mem_avail * 1024) - mem_used;
7676

77-
PrintAndLogEx(NORMAL, " --= Nonvolatile Program Memory Size: %uK bytes, Used: %u bytes (%2.0f\%) Free: %u bytes (%2.0f\%)",
77+
PrintAndLogEx(NORMAL, " --= Nonvolatile Program Memory Size: %uK bytes, Used: %u bytes (%2.0f%%) Free: %u bytes (%2.0f%%)",
7878
mem_avail,
7979
mem_used,
8080
mem_avail == 0 ? 0.0f : (float)mem_used/(mem_avail*1024)*100,

client/ui.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void PrintAndLogOptions(char *str[][2], size_t size, size_t space) {
4545
if(i<size-1)
4646
strncat(buff, "\n", sizeof(buff)-strlen(buff) -1);
4747
}
48-
PrintAndLogEx(NORMAL, buff);
48+
PrintAndLogEx(NORMAL, "%s", buff);
4949
}
5050
void PrintAndLogEx(logLevel_t level, char *fmt, ...) {
5151

@@ -86,7 +86,7 @@ void PrintAndLogEx(logLevel_t level, char *fmt, ...) {
8686

8787
// no prefixes for normal
8888
if ( level == NORMAL ) {
89-
PrintAndLog(buffer);
89+
PrintAndLog("%s", buffer);
9090
return;
9191
}
9292

@@ -111,10 +111,10 @@ void PrintAndLogEx(logLevel_t level, char *fmt, ...) {
111111

112112
token = strtok(NULL, delim);
113113
}
114-
PrintAndLog(buffer2);
114+
PrintAndLog("%s", buffer2);
115115
} else {
116116
snprintf(buffer2, sizeof(buffer2), "%s%s", prefix, buffer);
117-
PrintAndLog(buffer2);
117+
PrintAndLog("%s", buffer2);
118118
}
119119
}
120120

0 commit comments

Comments
 (0)