Skip to content

Commit 6f39418

Browse files
committed
Fix 32bit long used in long long printNumber.
1 parent e91a992 commit 6f39418

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: cores/esp32/Print.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ size_t Print::println(struct tm * timeinfo, const char * format)
278278

279279
size_t Print::printNumber(unsigned long n, uint8_t base)
280280
{
281-
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
281+
char buf[8 * sizeof(n) + 1]; // Assumes 8-bit chars plus zero byte.
282282
char *str = &buf[sizeof(buf) - 1];
283283

284284
*str = '\0';
@@ -291,16 +291,16 @@ size_t Print::printNumber(unsigned long n, uint8_t base)
291291
do {
292292
char c = n % base;
293293
n /= base;
294-
295-
*--str = c < 10 ? c + '0' : c + 'A' - 10;
296-
} while(n);
294+
295+
*--str = c < 10 ? c + '0' : c + 'A' - 10;
296+
} while (n);
297297

298298
return write(str);
299299
}
300300

301301
size_t Print::printNumber(unsigned long long n, uint8_t base)
302302
{
303-
char buf[8 * sizeof(long long) + 1]; // Assumes 8-bit chars plus zero byte.
303+
char buf[8 * sizeof(n) + 1]; // Assumes 8-bit chars plus zero byte.
304304
char* str = &buf[sizeof(buf) - 1];
305305

306306
*str = '\0';
@@ -311,7 +311,7 @@ size_t Print::printNumber(unsigned long long n, uint8_t base)
311311
}
312312

313313
do {
314-
unsigned long m = n;
314+
auto m = n;
315315
n /= base;
316316
char c = m - base * n;
317317

0 commit comments

Comments
 (0)