]> git.sur5r.net Git - i3/i3/blobdiff - src/display_version.c
Remove yajl major version conditionals
[i3/i3] / src / display_version.c
index 427c4ff7d69a52139cd755fbd1355290bd26d5c8..5b05c4b19f4b4e773615f47d72aa0bb32de55426 100644 (file)
 static bool human_readable_key;
 static char *human_readable_version;
 
-#if YAJL_MAJOR >= 2
 static int version_string(void *ctx, const unsigned char *val, size_t len) {
-#else
-static int version_string(void *ctx, const unsigned char *val, unsigned int len) {
-#endif
     if (human_readable_key)
         sasprintf(&human_readable_version, "%.*s", (int)len, val);
     return 1;
 }
 
-#if YAJL_MAJOR >= 2
 static int version_map_key(void *ctx, const unsigned char *stringval, size_t stringlen) {
-#else
-static int version_map_key(void *ctx, const unsigned char *stringval, unsigned int stringlen) {
-#endif
     human_readable_key = (stringlen == strlen("human_readable") &&
                    strncmp((const char*)stringval, "human_readable", strlen("human_readable")) == 0);
     return 1;
 }
 
 static yajl_callbacks version_callbacks = {
-    NULL, /* null */
-    NULL, /* boolean */
-    NULL, /* integer */
-    NULL, /* double */
-    NULL, /* number */
-    &version_string,
-    NULL, /* start_map */
-    &version_map_key,
-    NULL, /* end_map */
-    NULL, /* start_array */
-    NULL /* end_array */
+    .yajl_string = version_string,
+    .yajl_map_key = version_map_key,
 };
 
 /*
@@ -113,13 +96,7 @@ void display_running_version(void) {
     if (reply_type != I3_IPC_MESSAGE_TYPE_GET_VERSION)
         errx(EXIT_FAILURE, "Got reply type %d, but expected %d (GET_VERSION)", reply_type, I3_IPC_MESSAGE_TYPE_GET_VERSION);
 
-#if YAJL_MAJOR >= 2
     yajl_handle handle = yajl_alloc(&version_callbacks, NULL, NULL);
-#else
-    yajl_parser_config parse_conf = { 0, 0 };
-
-    yajl_handle handle = yajl_alloc(&version_callbacks, &parse_conf, NULL, NULL);
-#endif
 
     yajl_status state = yajl_parse(handle, (const unsigned char*)reply, (int)reply_length);
     if (state != yajl_status_ok)
@@ -135,7 +112,7 @@ void display_running_version(void) {
 
     sasprintf(&exepath, "/proc/%d/exe", getpid());
 
-    while ((linksize = readlink(exepath, destpath, destpath_size)) == destpath_size) {
+    while ((linksize = readlink(exepath, destpath, destpath_size)) == (ssize_t)destpath_size) {
             destpath_size = destpath_size * 2;
             destpath = srealloc(destpath, destpath_size);
     }
@@ -151,7 +128,7 @@ void display_running_version(void) {
     free(exepath);
     sasprintf(&exepath, "/proc/%s/exe", pid_from_atom);
 
-    while ((linksize = readlink(exepath, destpath, destpath_size)) == destpath_size) {
+    while ((linksize = readlink(exepath, destpath, destpath_size)) == (ssize_t)destpath_size) {
         destpath_size = destpath_size * 2;
         destpath = srealloc(destpath, destpath_size);
     }