Prefer intmax_t to size_t in xheader.c
* src/common.h (INTMAX_STRSIZE_BOUND): New constant. (SYSINT_BUFSIZE): Use it. * src/xheader.c (global_header_count, xheader_format_name): Prefer intmax_t to size_t, as the values are not sizes.
This commit is contained in:
11
src/common.h
11
src/common.h
@@ -688,9 +688,12 @@ represent_uintmax (uintmax_t n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { UINTMAX_STRSIZE_BOUND = INT_BUFSIZE_BOUND (uintmax_t) };
|
enum
|
||||||
enum { SYSINT_BUFSIZE =
|
{
|
||||||
max (UINTMAX_STRSIZE_BOUND, INT_BUFSIZE_BOUND (intmax_t)) };
|
INTMAX_STRSIZE_BOUND = INT_BUFSIZE_BOUND (intmax_t),
|
||||||
|
UINTMAX_STRSIZE_BOUND = INT_BUFSIZE_BOUND (uintmax_t),
|
||||||
|
SYSINT_BUFSIZE = max (INTMAX_STRSIZE_BOUND, UINTMAX_STRSIZE_BOUND)
|
||||||
|
};
|
||||||
char *sysinttostr (uintmax_t, intmax_t, uintmax_t, char buf[SYSINT_BUFSIZE]);
|
char *sysinttostr (uintmax_t, intmax_t, uintmax_t, char buf[SYSINT_BUFSIZE]);
|
||||||
intmax_t stoint (char const *, char **, bool *, intmax_t, uintmax_t);
|
intmax_t stoint (char const *, char **, bool *, intmax_t, uintmax_t);
|
||||||
char *timetostr (time_t, char buf[SYSINT_BUFSIZE]);
|
char *timetostr (time_t, char buf[SYSINT_BUFSIZE]);
|
||||||
@@ -903,7 +906,7 @@ void xheader_string_add (struct xheader *xhdr, char const *s);
|
|||||||
bool xheader_string_end (struct xheader *xhdr, char const *keyword);
|
bool xheader_string_end (struct xheader *xhdr, char const *keyword);
|
||||||
bool xheader_keyword_deleted_p (const char *kw);
|
bool xheader_keyword_deleted_p (const char *kw);
|
||||||
char *xheader_format_name (struct tar_stat_info *st, const char *fmt,
|
char *xheader_format_name (struct tar_stat_info *st, const char *fmt,
|
||||||
size_t n);
|
intmax_t n);
|
||||||
void xheader_xattr_init (struct tar_stat_info *st);
|
void xheader_xattr_init (struct tar_stat_info *st);
|
||||||
|
|
||||||
void xattr_map_init (struct xattr_map *map);
|
void xattr_map_init (struct xattr_map *map);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ static void code_string (char const *string, char const *keyword,
|
|||||||
struct xheader *xhdr);
|
struct xheader *xhdr);
|
||||||
|
|
||||||
/* Number of global headers written so far. */
|
/* Number of global headers written so far. */
|
||||||
static size_t global_header_count;
|
static intmax_t global_header_count;
|
||||||
/* FIXME: Possibly it should be reset after changing the volume.
|
/* FIXME: Possibly it should be reset after changing the volume.
|
||||||
POSIX %n specification says that it is expanded to the sequence
|
POSIX %n specification says that it is expanded to the sequence
|
||||||
number of current global header in *the* archive. However, for
|
number of current global header in *the* archive. However, for
|
||||||
@@ -254,7 +254,7 @@ xheader_set_option (char *string)
|
|||||||
%% A '%' character. */
|
%% A '%' character. */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
xheader_format_name (struct tar_stat_info *st, const char *fmt, size_t n)
|
xheader_format_name (struct tar_stat_info *st, const char *fmt, intmax_t n)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t len;
|
size_t len;
|
||||||
@@ -265,7 +265,7 @@ xheader_format_name (struct tar_stat_info *st, const char *fmt, size_t n)
|
|||||||
char *base = NULL;
|
char *base = NULL;
|
||||||
char pidbuf[UINTMAX_STRSIZE_BOUND];
|
char pidbuf[UINTMAX_STRSIZE_BOUND];
|
||||||
char const *pptr = NULL;
|
char const *pptr = NULL;
|
||||||
char nbuf[UINTMAX_STRSIZE_BOUND];
|
char nbuf[INTMAX_STRSIZE_BOUND];
|
||||||
char const *nptr = NULL;
|
char const *nptr = NULL;
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
@@ -303,7 +303,7 @@ xheader_format_name (struct tar_stat_info *st, const char *fmt, size_t n)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
nptr = umaxtostr (n, nbuf);
|
nptr = imaxtostr (n, nbuf);
|
||||||
len += nbuf + sizeof nbuf - 1 - nptr;
|
len += nbuf + sizeof nbuf - 1 - nptr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user