misc: improve string to number conversions
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
97b7dcf32e
commit
28941d202a
|
@ -1432,7 +1432,6 @@ static void parse_argv(int argc, char *argv[])
|
||||||
int opts_for_fsck = 0;
|
int opts_for_fsck = 0;
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
int report_stats_fd = -1;
|
int report_stats_fd = -1;
|
||||||
uint64_t num;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up signal action
|
* Set up signal action
|
||||||
|
@ -1605,8 +1604,8 @@ static void parse_argv(int argc, char *argv[])
|
||||||
|
|
||||||
if (getenv("FSCK_FORCE_ALL_PARALLEL"))
|
if (getenv("FSCK_FORCE_ALL_PARALLEL"))
|
||||||
force_all_parallel++;
|
force_all_parallel++;
|
||||||
if (ul_strtou64(getenv("FSCK_MAX_INST"), &num, 10) == 0 && num <= INT_MAX)
|
if (ul_strtos32(getenv("FSCK_MAX_INST"), &max_running, 10) != 0)
|
||||||
max_running = num;
|
max_running = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|
|
@ -526,15 +526,15 @@ static int read_speed(const char *devname)
|
||||||
/* find line "drive speed" and read the correct speed */
|
/* find line "drive speed" and read the correct speed */
|
||||||
} else {
|
} else {
|
||||||
if (strncmp(line, "drive speed:", 12) == 0) {
|
if (strncmp(line, "drive speed:", 12) == 0) {
|
||||||
uint64_t n;
|
int n;
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
str = line + 12;
|
str = line + 12;
|
||||||
normalize_whitespace((unsigned char *) str);
|
normalize_whitespace((unsigned char *) str);
|
||||||
|
|
||||||
if (ul_strtou64(str, &n, 10) == 0 && n <= INT_MAX)
|
if (ul_strtos32(str, &n, 10) == 0)
|
||||||
return (int) n;
|
return n;
|
||||||
|
|
||||||
errx(EXIT_FAILURE, _("%s: failed to read speed"),
|
errx(EXIT_FAILURE, _("%s: failed to read speed"),
|
||||||
_PATH_PROC_CDROMINFO);
|
_PATH_PROC_CDROMINFO);
|
||||||
|
|
|
@ -497,8 +497,8 @@ int lscpu_read_cpuinfo(struct lscpu_cxt *cxt)
|
||||||
if (keynum >= 0)
|
if (keynum >= 0)
|
||||||
id = keynum;
|
id = keynum;
|
||||||
else {
|
else {
|
||||||
uint64_t n;
|
uint32_t n;
|
||||||
if (ul_strtou64(value, &n, 10) == 0 && n <= INT_MAX)
|
if (ul_strtou32(value, &n, 10) == 0)
|
||||||
id = n;
|
id = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,15 +317,14 @@ static void getwinsize(void)
|
||||||
struct winsize winsz;
|
struct winsize winsz;
|
||||||
int badioctl;
|
int badioctl;
|
||||||
#endif
|
#endif
|
||||||
char *p;
|
|
||||||
|
|
||||||
if (initialized == 0) {
|
if (initialized == 0) {
|
||||||
if ((p = getenv("LINES")) != NULL && *p != '\0')
|
uint32_t tmp = 0;
|
||||||
if ((envlines = atoi(p)) < 0)
|
|
||||||
envlines = 0;
|
if (ul_strtou32(getenv("LINES"), &tmp, 10) == 0)
|
||||||
if ((p = getenv("COLUMNS")) != NULL && *p != '\0')
|
envlines = tmp;
|
||||||
if ((envcols = atoi(p)) < 0)
|
if (ul_strtou32(getenv("COLUMNS"), &tmp, 10) == 0)
|
||||||
envcols = 0;
|
envcols = tmp;
|
||||||
|
|
||||||
/* terminfo values. */
|
/* terminfo values. */
|
||||||
if (tinfostat != 1 || columns == 0)
|
if (tinfostat != 1 || columns == 0)
|
||||||
defcols = 24;
|
defcols = 24;
|
||||||
|
|
Loading…
Reference in New Issue