mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 10:01:01 +03:00
zdb: remove strtok
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12094
This commit is contained in:
parent
1ce6d70c52
commit
a0d7e27a13
@ -3591,7 +3591,7 @@ static int
|
|||||||
parse_object_range(char *range, zopt_object_range_t *zor, char **msg)
|
parse_object_range(char *range, zopt_object_range_t *zor, char **msg)
|
||||||
{
|
{
|
||||||
uint64_t flags = 0;
|
uint64_t flags = 0;
|
||||||
char *p, *s, *dup, *flagstr;
|
char *p, *s, *dup, *flagstr, *tmp = NULL;
|
||||||
size_t len;
|
size_t len;
|
||||||
int i;
|
int i;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
@ -3620,7 +3620,7 @@ parse_object_range(char *range, zopt_object_range_t *zor, char **msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dup = strdup(range);
|
dup = strdup(range);
|
||||||
s = strtok(dup, ":");
|
s = strtok_r(dup, ":", &tmp);
|
||||||
zor->zor_obj_start = strtoull(s, &p, 0);
|
zor->zor_obj_start = strtoull(s, &p, 0);
|
||||||
|
|
||||||
if (*p != '\0') {
|
if (*p != '\0') {
|
||||||
@ -3629,7 +3629,7 @@ parse_object_range(char *range, zopt_object_range_t *zor, char **msg)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = strtok(NULL, ":");
|
s = strtok_r(NULL, ":", &tmp);
|
||||||
zor->zor_obj_end = strtoull(s, &p, 0);
|
zor->zor_obj_end = strtoull(s, &p, 0);
|
||||||
|
|
||||||
if (*p != '\0') {
|
if (*p != '\0') {
|
||||||
@ -3644,11 +3644,11 @@ parse_object_range(char *range, zopt_object_range_t *zor, char **msg)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = strtok(NULL, ":");
|
s = strtok_r(NULL, ":", &tmp);
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
zor->zor_flags = ZOR_FLAG_ALL_TYPES;
|
zor->zor_flags = ZOR_FLAG_ALL_TYPES;
|
||||||
goto out;
|
goto out;
|
||||||
} else if (strtok(NULL, ":") != NULL) {
|
} else if (strtok_r(NULL, ":", &tmp) != NULL) {
|
||||||
*msg = "Invalid colon-delimited field after flags";
|
*msg = "Invalid colon-delimited field after flags";
|
||||||
rc = 1;
|
rc = 1;
|
||||||
goto out;
|
goto out;
|
||||||
@ -7859,15 +7859,15 @@ name_from_objset_id(spa_t *spa, uint64_t objset_id, char *outstr)
|
|||||||
static boolean_t
|
static boolean_t
|
||||||
zdb_parse_block_sizes(char *sizes, uint64_t *lsize, uint64_t *psize)
|
zdb_parse_block_sizes(char *sizes, uint64_t *lsize, uint64_t *psize)
|
||||||
{
|
{
|
||||||
char *s0, *s1;
|
char *s0, *s1, *tmp = NULL;
|
||||||
|
|
||||||
if (sizes == NULL)
|
if (sizes == NULL)
|
||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
|
|
||||||
s0 = strtok(sizes, "/");
|
s0 = strtok_r(sizes, "/", &tmp);
|
||||||
if (s0 == NULL)
|
if (s0 == NULL)
|
||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
s1 = strtok(NULL, "/");
|
s1 = strtok_r(NULL, "/", &tmp);
|
||||||
*lsize = strtoull(s0, NULL, 16);
|
*lsize = strtoull(s0, NULL, 16);
|
||||||
*psize = s1 ? strtoull(s1, NULL, 16) : *lsize;
|
*psize = s1 ? strtoull(s1, NULL, 16) : *lsize;
|
||||||
return (*lsize >= *psize && *psize > 0);
|
return (*lsize >= *psize && *psize > 0);
|
||||||
@ -7984,20 +7984,21 @@ zdb_read_block(char *thing, spa_t *spa)
|
|||||||
vdev_t *vd;
|
vdev_t *vd;
|
||||||
abd_t *pabd;
|
abd_t *pabd;
|
||||||
void *lbuf, *buf;
|
void *lbuf, *buf;
|
||||||
char *s, *p, *dup, *vdev, *flagstr, *sizes;
|
char *s, *p, *dup, *vdev, *flagstr, *sizes, *tmp = NULL;
|
||||||
int i, error;
|
int i, error;
|
||||||
boolean_t borrowed = B_FALSE, found = B_FALSE;
|
boolean_t borrowed = B_FALSE, found = B_FALSE;
|
||||||
|
|
||||||
dup = strdup(thing);
|
dup = strdup(thing);
|
||||||
s = strtok(dup, ":");
|
s = strtok_r(dup, ":", &tmp);
|
||||||
vdev = s ? s : "";
|
vdev = s ? s : "";
|
||||||
s = strtok(NULL, ":");
|
s = strtok_r(NULL, ":", &tmp);
|
||||||
offset = strtoull(s ? s : "", NULL, 16);
|
offset = strtoull(s ? s : "", NULL, 16);
|
||||||
sizes = strtok(NULL, ":");
|
sizes = strtok_r(NULL, ":", &tmp);
|
||||||
s = strtok(NULL, ":");
|
s = strtok_r(NULL, ":", &tmp);
|
||||||
flagstr = strdup(s ? s : "");
|
flagstr = strdup(s ? s : "");
|
||||||
|
|
||||||
s = NULL;
|
s = NULL;
|
||||||
|
tmp = NULL;
|
||||||
if (!zdb_parse_block_sizes(sizes, &lsize, &psize))
|
if (!zdb_parse_block_sizes(sizes, &lsize, &psize))
|
||||||
s = "invalid size(s)";
|
s = "invalid size(s)";
|
||||||
if (!IS_P2ALIGNED(psize, DEV_BSIZE) || !IS_P2ALIGNED(lsize, DEV_BSIZE))
|
if (!IS_P2ALIGNED(psize, DEV_BSIZE) || !IS_P2ALIGNED(lsize, DEV_BSIZE))
|
||||||
@ -8009,7 +8010,9 @@ zdb_read_block(char *thing, spa_t *spa)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (s = strtok(flagstr, ":"); s; s = strtok(NULL, ":")) {
|
for (s = strtok_r(flagstr, ":", &tmp);
|
||||||
|
s != NULL;
|
||||||
|
s = strtok_r(NULL, ":", &tmp)) {
|
||||||
for (i = 0; i < strlen(flagstr); i++) {
|
for (i = 0; i < strlen(flagstr); i++) {
|
||||||
int bit = flagbits[(uchar_t)flagstr[i]];
|
int bit = flagbits[(uchar_t)flagstr[i]];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user