aboutsummaryrefslogtreecommitdiffstats
path: root/strtotimespec.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-06-11 16:37:09 +0200
committerMattias Andrée <maandree@kth.se>2022-06-11 16:37:09 +0200
commitfcfe59c1f2219408ac2a9cd84b386816ff252221 (patch)
tree0f46c009babfba2d0200ece3ecce067c548a66b6 /strtotimespec.c
parentRemove `static` from some `static inline` (diff)
downloadlibsimple-fcfe59c1f2219408ac2a9cd84b386816ff252221.tar.gz
libsimple-fcfe59c1f2219408ac2a9cd84b386816ff252221.tar.bz2
libsimple-fcfe59c1f2219408ac2a9cd84b386816ff252221.tar.xz
Fix warnings, replace some static inline with inline + extern inline, and fix glibc support
Diffstat (limited to 'strtotimespec.c')
-rw-r--r--strtotimespec.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/strtotimespec.c b/strtotimespec.c
index d6bd64c..7c1494e 100644
--- a/strtotimespec.c
+++ b/strtotimespec.c
@@ -11,9 +11,12 @@ libsimple_strtotimespec(struct timespec *restrict ts, const char *restrict s, ch
long int nsec = 0;
long int mul = 100000000L;
const char *p;
+ const char *end_s;
- if (end)
- *end = (void *)s;
+ if (end) {
+ end_s = s;
+ *end = REMOVE_CONST(end_s, char *);
+ }
while (isspace(*s))
s++;
@@ -58,8 +61,10 @@ libsimple_strtotimespec(struct timespec *restrict ts, const char *restrict s, ch
if (*s != '.') {
ts->tv_sec = sec;
ts->tv_nsec = 0;
- if (end)
- *end = (void *)s;
+ if (end) {
+ end_s = s;
+ *end = REMOVE_CONST(end_s, char *);
+ }
return 0;
}
@@ -85,7 +90,7 @@ libsimple_strtotimespec(struct timespec *restrict ts, const char *restrict s, ch
}
}
if (end)
- *end = (void *)p;
+ *end = REMOVE_CONST(p, char *);
p = s;
while (mul) {
for (s = p; mul && isdigit(*s); s++) {
@@ -118,8 +123,10 @@ libsimple_strtotimespec(struct timespec *restrict ts, const char *restrict s, ch
while (isdigit(*s))
s++;
}
- if (end)
- *end = (void *)s;
+ if (end) {
+ end_s = s;
+ *end = REMOVE_CONST(end_s, char *);
+ }
}
if (neg && nsec) {
@@ -164,8 +171,10 @@ overflow_periodic:
}
overflow:
- if (end)
- *end = (void *)s;
+ if (end) {
+ end_s = s;
+ *end = REMOVE_CONST(end_s, char *);
+ }
if (neg) {
ts->tv_sec = TIME_MIN;
ts->tv_nsec = 0;