From 7f602784de4fd378120e8ebfe6d830862b9cae03 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 2 Apr 2013 20:38:16 +0200 Subject: 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. --- src/shared/conf-parser.c | 4 ++-- src/shared/conf-parser.h | 2 +- src/shared/time-util.c | 10 +++++----- src/shared/time-util.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/shared') diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index c2cf5a6a19..a87df382ea 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -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; } diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index 9096c605e2..88194f6771 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -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); diff --git a/src/shared/time-util.c b/src/shared/time-util.c index 0c6deb66f4..e27aaf6c6a 100644 --- a/src/shared/time-util.c +++ b/src/shared/time-util.c @@ -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; diff --git a/src/shared/time-util.h b/src/shared/time-util.h index ec263c1a19..2e3b0f5744 100644 --- a/src/shared/time-util.h +++ b/src/shared/time-util.h @@ -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); -- cgit v1.2.3-54-g00ecf