]> granicus.if.org Git - pgbouncer/commitdiff
system.h + types cleanup
authorMarko Kreen <markokr@gmail.com>
Thu, 14 Feb 2008 13:38:52 +0000 (13:38 +0000)
committerMarko Kreen <markokr@gmail.com>
Thu, 14 Feb 2008 13:38:52 +0000 (13:38 +0000)
- use proper printf args from inttypes.h instead of casting to ull
- remove unused macros
- tag replacement functions as _mustcheck

include/system.h
src/pktbuf.c
src/stats.c

index 9ef317ba9ab183616d84d27949bda77afde319ac..a06401ea34892cd625d4f03df02daf71779640d2 100644 (file)
@@ -24,8 +24,6 @@
 #include "config.h"
 #endif
 
-#define _GNU_SOURCE
-
 #include <sys/errno.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #define FLEX_ARRAY 1
 #endif
 
-/* gcc has hew positive aspects too */
 #ifdef __GNUC__
 
-#define unlikely(x) __builtin_expect(!!(x), 0)
-#define likely(x) __builtin_expect(!!(x), 1)
-
+/* gcc has hew positive aspects too */
 #define _MUSTCHECK             __attribute__((warn_unused_result))
 #define _DEPRECATED            __attribute__((deprecated))
 #define _PRINTF(fmtpos, argpos)        __attribute__((format(printf, fmtpos, argpos)))
 #define _MALLOC                        __attribute__((malloc))
 
-#if 0
-#define _USED                  __attribute__((used))
-#define _UNUSED                        __attribute__((unused))
-#define _NONNULL(args...)      __attribute__((nonnull(args)))
-#define _REGPARM(num)          __attribute__((regparm(num)))
-#define _FASTCALL              __attribute__((fastcall))
-#endif
+/* those do not seem to work well */
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#define likely(x) __builtin_expect(!!(x), 1)
 
 #else
 
-#define unlikely(x) x
-#define likely(x) x
-
 #define _MUSTCHECK
 #define _DEPRECATED
 #define _PRINTF(x,y)
 #define _MALLOC
+#define unlikely(x) x
+#define likely(x) x
 
 #endif
 
@@ -110,7 +100,6 @@ do { \
 #endif
 
 #ifndef UNIX_PATH_MAX
-/* #define UNIX_PATH_MAX  (sizeof(((struct sockaddr_un *)0)->sun_path)) */
 #define UNIX_PATH_MAX  128 /* actual sizeof() will be applied later anyway */
 #endif
 
@@ -119,9 +108,6 @@ do { \
 
 typedef uint64_t usec_t;
 
-/* shortcut to simplify printf of u64 types */
-typedef unsigned long long ull_t;
-
 /*
  * bool type.
  */
@@ -143,13 +129,13 @@ typedef unsigned char bool;
  */
 
 #ifndef HAVE_STRLCPY
-size_t strlcpy(char *dst, const char *src, size_t n);
+size_t strlcpy(char *dst, const char *src, size_t n) _MUSTCHECK;
 #endif
 #ifndef HAVE_STRLCAT
-size_t strlcat(char *dst, const char *src, size_t n);
+size_t strlcat(char *dst, const char *src, size_t n) _MUSTCHECK;
 #endif
 #ifndef HAVE_GETPEEREID
-int getpeereid(int fd, uid_t *uid_p, gid_t *gid_p);
+int getpeereid(int fd, uid_t *uid_p, gid_t *gid_p) _MUSTCHECK;
 #endif
 
 /*
@@ -200,4 +186,3 @@ static inline int _inline_strcmp(const char *a, const char *b)
 #undef strcmp
 #define strcmp(a, b) _inline_strcmp(a, b)
 
-
index 88b6d478dcb9651cb3bf427350bc6d3a565f3554..6c18923e51804c25af4edeb2d8a211a5365ad88b 100644 (file)
@@ -384,7 +384,7 @@ void pktbuf_write_DataRow(PktBuf *buf, const char *tupdesc, ...)
                        sprintf(tmp, "%d", va_arg(ap, int));
                        val = tmp;
                } else if (tupdesc[i] == 'q') {
-                       sprintf(tmp, "%llu", (unsigned long long)va_arg(ap, uint64_t));
+                       sprintf(tmp, "%" PRIu64, va_arg(ap, uint64_t));
                        val = tmp;
                } else if (tupdesc[i] == 's') {
                        val = va_arg(ap, char *);
index cb83581155f023134e57c05bdf3e1ecce9056a23..385904bf7a3258f117175d01fe798972f751dfe3 100644 (file)
@@ -188,10 +188,12 @@ static void refresh_stats(int s, short flags, void *arg)
        }
        calc_average(&avg, &cur_total, &old_total);
        /* send totals to logfile */
-       log_info("Stats: %llu req/s, in %llu b/s, "
-                "out %llu b/s, query %llu us",
-                (ull_t)avg.request_count, (ull_t)avg.client_bytes,
-                (ull_t)avg.server_bytes, (ull_t)avg.query_time);
+       log_info("Stats: %" PRIu64 " req/s,"
+                " in %" PRIu64 " b/s,"
+                " out %" PRIu64 " b/s,"
+                "query %" PRIu64 " us",
+                avg.request_count, avg.client_bytes,
+                avg.server_bytes, avg.query_time);
 
        safe_evtimer_add(&ev_stats, &period);
 }