util: rename parse_usec() to parse_sec() sinds the default unit is seconds

Internally we store all time values in usec_t, however parse_usec()
actually was used mostly to parse values in seconds (unless explicit
units were specified to define a different unit). Hence, be clear about
this and name the function about what we pass into it, not what we get
out of it.
This commit is contained in:
Lennart Poettering
2013-04-03 20:12:57 +02:00
parent 574d5f2dfc
commit 7f602784de
16 changed files with 35 additions and 35 deletions
+2 -2
View File
@@ -792,7 +792,7 @@ int config_parse_path_strv(
return 0;
}
int config_parse_usec(
int config_parse_sec(
const char *filename,
unsigned line,
const char *section,
@@ -809,7 +809,7 @@ int config_parse_usec(
assert(rvalue);
assert(data);
if (parse_usec(rvalue, usec) < 0) {
if (parse_sec(rvalue, usec) < 0) {
log_error("[%s:%u] Failed to parse time value, ignoring: %s", filename, line, rvalue);
return 0;
}
+1 -1
View File
@@ -101,7 +101,7 @@ int config_parse_string(const char *filename, unsigned line, const char *section
int config_parse_path(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_strv(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_path_strv(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_usec(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_sec(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_nsec(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_mode(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_facility(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+5 -5
View File
@@ -256,7 +256,7 @@ char *format_timespan(char *buf, size_t l, usec_t t) {
return p;
}
/* The result of this function can be parsed with parse_usec */
/* The result of this function can be parsed with parse_sec */
for (i = 0; i < ELEMENTSOF(table); i++) {
int k;
@@ -382,14 +382,14 @@ int parse_timestamp(const char *t, usec_t *usec) {
} else if (t[0] == '+') {
r = parse_usec(t+1, &plus);
r = parse_sec(t+1, &plus);
if (r < 0)
return r;
goto finish;
} else if (t[0] == '-') {
r = parse_usec(t+1, &minus);
r = parse_sec(t+1, &minus);
if (r < 0)
return r;
@@ -402,7 +402,7 @@ int parse_timestamp(const char *t, usec_t *usec) {
if (!z)
return -ENOMEM;
r = parse_usec(z, &minus);
r = parse_sec(z, &minus);
if (r < 0)
return r;
@@ -497,7 +497,7 @@ finish:
return 0;
}
int parse_usec(const char *t, usec_t *usec) {
int parse_sec(const char *t, usec_t *usec) {
static const struct {
const char *suffix;
usec_t usec;
+1 -1
View File
@@ -80,5 +80,5 @@ void dual_timestamp_deserialize(const char *value, dual_timestamp *t);
int parse_timestamp(const char *t, usec_t *usec);
int parse_usec(const char *t, usec_t *usec);
int parse_sec(const char *t, usec_t *usec);
int parse_nsec(const char *t, nsec_t *nsec);