1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[fmt] Fix incorrect format specifiers in printf

* Since tm.* members are ints, apply cast to unsigned int to format
  them correctly via printf.
* I64d(u) is not correct format specifier for long long (unsigned),
  since such types can be more than 64 bit long. Either use platform
  -specific (u)int64_t, or, better, change format specifier to %lld /
  %llu. See https://stackoverflow.com/questions/15718039/why-the-use-of-cin-cout-or-i64d-is-preferred-over-lld-specifier-in-c for details.
This commit is contained in:
Tsarevich Dmitry 2020-02-18 01:33:20 +03:00
parent 45acbeba2c
commit 75a874d7e5
2 changed files with 15 additions and 15 deletions

View file

@ -33,13 +33,13 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
bb_mode_string(file_header->mode),
user,
group,
file_header->size,
1900 + ptm->tm_year,
1 + ptm->tm_mon,
ptm->tm_mday,
ptm->tm_hour,
ptm->tm_min,
ptm->tm_sec,
(unsigned long long)file_header->size,
1900U + (unsigned)ptm->tm_year,
1U + (unsigned)ptm->tm_mon,
(unsigned)ptm->tm_mday,
(unsigned)ptm->tm_hour,
(unsigned)ptm->tm_min,
(unsigned)ptm->tm_sec,
file_header->name);
#else /* !FEATURE_TAR_UNAME_GNAME */
@ -50,13 +50,13 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
bb_mode_string(file_header->mode),
(unsigned)file_header->uid,
(unsigned)file_header->gid,
file_header->size,
1900 + ptm->tm_year,
1 + ptm->tm_mon,
ptm->tm_mday,
ptm->tm_hour,
ptm->tm_min,
ptm->tm_sec,
(unsigned long long)file_header->size,
1900U + (unsigned)ptm->tm_year,
1U + (unsigned)ptm->tm_mon,
(unsigned)ptm->tm_mday,
(unsigned)ptm->tm_hour,
(unsigned)ptm->tm_min,
(unsigned)ptm->tm_sec,
file_header->name);
#endif /* FEATURE_TAR_UNAME_GNAME */

View file

@ -46,7 +46,7 @@
#define IF_NOT_FEATURE_LZMA_FAST(x) x
#define uoff_t unsigned off_t
#define OFF_FMT "I64"
#define OFF_FMT "ll"
#ifndef _MODE_T_
#define _MODE_T_