comparison dbutil.c @ 953:356a25a108a3

Fix some format string warnings
author Matt Johnston <matt@ucc.asn.au>
date Mon, 28 Jul 2014 22:59:16 +0800
parents ef8d939de3dd
children db9fa5971d24
comparison
equal deleted inserted replaced
952:ef8d939de3dd 953:356a25a108a3
159 } 159 }
160 160
161 gettimeofday(&tv, NULL); 161 gettimeofday(&tv, NULL);
162 162
163 va_start(param, format); 163 va_start(param, format);
164 fprintf(stderr, "TRACE (%d) %d.%d: ", getpid(), tv.tv_sec, tv.tv_usec); 164 fprintf(stderr, "TRACE (%d) %d.%d: ", getpid(), (int)tv.tv_sec, (int)tv.tv_usec);
165 vfprintf(stderr, format, param); 165 vfprintf(stderr, format, param);
166 fprintf(stderr, "\n"); 166 fprintf(stderr, "\n");
167 va_end(param); 167 va_end(param);
168 } 168 }
169 169
181 } 181 }
182 182
183 gettimeofday(&tv, NULL); 183 gettimeofday(&tv, NULL);
184 184
185 va_start(param, format); 185 va_start(param, format);
186 fprintf(stderr, "TRACE2 (%d) %d.%d: ", getpid(), tv.tv_sec, tv.tv_usec); 186 fprintf(stderr, "TRACE2 (%d) %d.%d: ", getpid(), (int)tv.tv_sec, (int)tv.tv_usec);
187 vfprintf(stderr, format, param); 187 vfprintf(stderr, format, param);
188 fprintf(stderr, "\n"); 188 fprintf(stderr, "\n");
189 va_end(param); 189 va_end(param);
190 } 190 }
191 #endif /* DEBUG_TRACE */ 191 #endif /* DEBUG_TRACE */
954 static clockid_t get_linux_clock_source() { 954 static clockid_t get_linux_clock_source() {
955 struct timespec ts; 955 struct timespec ts;
956 if (syscall(SYS_clock_gettime, CLOCK_MONOTONIC_COARSE, &ts) == 0) { 956 if (syscall(SYS_clock_gettime, CLOCK_MONOTONIC_COARSE, &ts) == 0) {
957 return CLOCK_MONOTONIC_COARSE; 957 return CLOCK_MONOTONIC_COARSE;
958 } 958 }
959
959 if (syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &ts) == 0) { 960 if (syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &ts) == 0) {
960 return CLOCK_MONOTONIC; 961 return CLOCK_MONOTONIC;
961 } 962 }
962 return -1; 963 return -1;
963 } 964 }
966 time_t monotonic_now() { 967 time_t monotonic_now() {
967 #if defined(__linux__) && defined(SYS_clock_gettime) 968 #if defined(__linux__) && defined(SYS_clock_gettime)
968 static clockid_t clock_source = -2; 969 static clockid_t clock_source = -2;
969 970
970 if (clock_source == -2) { 971 if (clock_source == -2) {
971 /* First time, find out which one works. 972 /* First run, find out which one works.
972 -1 will fall back to time() */ 973 -1 will fall back to time() */
973 clock_source = get_linux_clock_source(); 974 clock_source = get_linux_clock_source();
974 } 975 }
975 976
976 if (clock_source >= 0) { 977 if (clock_source >= 0) {