kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 190315c23802569abc04b6d623149edb7a79923e
parent 49df7a313bbd2d3fc7b21cb2b17b3724e8237d55
Author: Joris Vink <joris@coders.se>
Date:   Tue, 15 Oct 2013 13:33:35 +0200

Make inject.c no longer spew warnings, instead use correct widths for time_t on all platforms.

Diffstat:
modules/example/tools/inject.c | 26+++++++++++++++++++-------
modules/skeleton/tools/inject.c | 26+++++++++++++++++++-------
2 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/modules/example/tools/inject.c b/modules/example/tools/inject.c @@ -27,6 +27,22 @@ #include <string.h> #include <unistd.h> +#if defined(OpenBSD) +#define PRI_TIME_T "d" +#endif + +#if defined(linux) +#if defined(__x86_64__) +#define PRI_TIME_T PRIu64 +#else +#define PRI_TIME_T "ld" +#endif +#endif + +#if defined(__MACH__) +#define PRI_TIME_T "ld" +#endif + int main(int argc, char *argv[]) { @@ -88,15 +104,11 @@ main(int argc, char *argv[]) close(fd); printf("};\n\n"); - printf("u_int32_t static_len_%s_%s = %" PRId64 ";\n", - ext, argv[2], st.st_size); + printf("u_int32_t static_len_%s_%s = %" PRIu32 ";\n", + ext, argv[2], (u_int32_t)st.st_size); -#if defined(OpenBSD) - printf("time_t static_mtime_%s_%s = %d;\n", ext, argv[2], st.st_mtime); -#else - printf("time_t static_mtime_%s_%s = %" PRId64 ";\n", + printf("time_t static_mtime_%s_%s = %" PRI_TIME_T ";\n", ext, argv[2], st.st_mtime); -#endif fprintf(hdr, "extern u_int8_t static_%s_%s[];\n", ext, argv[2]); fprintf(hdr, "extern u_int32_t static_len_%s_%s;\n", ext, argv[2]); diff --git a/modules/skeleton/tools/inject.c b/modules/skeleton/tools/inject.c @@ -27,6 +27,22 @@ #include <string.h> #include <unistd.h> +#if defined(OpenBSD) +#define PRI_TIME_T "d" +#endif + +#if defined(linux) +#if defined(__x86_64__) +#define PRI_TIME_T PRIu64 +#else +#define PRI_TIME_T "ld" +#endif +#endif + +#if defined(__MACH__) +#define PRI_TIME_T "ld" +#endif + int main(int argc, char *argv[]) { @@ -88,15 +104,11 @@ main(int argc, char *argv[]) close(fd); printf("};\n\n"); - printf("u_int32_t static_len_%s_%s = %" PRId64 ";\n", - ext, argv[2], st.st_size); + printf("u_int32_t static_len_%s_%s = %" PRIu32 ";\n", + ext, argv[2], (u_int32_t)st.st_size); -#if defined(OpenBSD) - printf("time_t static_mtime_%s_%s = %d;\n", ext, argv[2], st.st_mtime); -#else - printf("time_t static_mtime_%s_%s = %" PRId64 ";\n", + printf("time_t static_mtime_%s_%s = %" PRI_TIME_T ";\n", ext, argv[2], st.st_mtime); -#endif fprintf(hdr, "extern u_int8_t static_%s_%s[];\n", ext, argv[2]); fprintf(hdr, "extern u_int32_t static_len_%s_%s;\n", ext, argv[2]);