]> git.itanic.dy.fi Git - rrdd/blobdiff - utils.h
onewire_parser.c: Fix compiler warnings about string lengths
[rrdd] / utils.h
diff --git a/utils.h b/utils.h
index cdb082f3b5ea1fcfe7f495742d5f4a56c23c5f01..14133cdbee1607920fff43f187619ac32e20b5f7 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -25,4 +25,24 @@ int _mutex_unlock(struct mutex *lock);
 #define mutex_unlock(lock) _mutex_unlock(lock)
 #define mutex_lock_acquired(lock) _mutex_lock_acquired(lock, __FILE__, __LINE__)
 
+static inline char *_strlcat(char *dst, const char *src, size_t len)
+{
+       strncat(dst, src, len - strnlen(dst, len) - 1);
+       dst[len - 1] = '\0';
+
+       return dst;
+}
+
+static inline int mutex_init(struct mutex *mutex)
+{
+       mutex->line = 0;
+       mutex->owner_name[0] = '\0';
+       mutex->lock_time = 0;
+       mutex->name = NULL;
+
+       return pthread_mutex_init(&mutex->lock, NULL);
+}
+
+#define ROUND_UP(a, m) ((a) + (m) - (a) % (m))
+
 #endif