Move errno-protection into string_open_failed()
[users/heiko/exim.git] / src / src / lookups / json.c
index 487b9b52d21e08f310412a402189f44e9803c3de..9b1fe78ed3b4e9d17e20ee8863d74563ac096302 100644 (file)
@@ -2,7 +2,7 @@
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) Jeremy Harris 2019 */
+/* Copyright (c) Jeremy Harris 2019-2020 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 #include "../exim.h"
@@ -47,12 +47,7 @@ FILE * f;
 json_set_alloc_funcs(json_malloc, json_free);
 
 if (!(f = Ufopen(filename, "rb")))
-  {
-  int save_errno = errno;
-  *errmsg = string_open_failed(errno, "%s for json search", filename);
-  errno = save_errno;
-  return NULL;
-  }
+  *errmsg = string_open_failed("%s for json search", filename);
 return f;
 }
 
@@ -89,9 +84,6 @@ json_error_t jerr;
 uschar * key;
 int sep = 0;
 
-length = length;       /* Keep picky compilers happy */
-do_cache = do_cache;   /* Keep picky compilers happy */
-
 rewind(f);
 if (!(j = json_loadf(f, 0, &jerr)))
   {
@@ -173,15 +165,15 @@ fprintf(f, "Library version: json: Jansonn version %s\n", JANSSON_VERSION);
 
 
 static lookup_info json_lookup_info = {
-  US"json",                      /* lookup name */
-  lookup_absfile,                /* uses absolute file name */
-  json_open,                  /* open function */
-  json_check,                 /* check function */
-  json_find,                  /* find function */
-  json_close,                 /* close function */
-  NULL,                          /* no tidy function */
-  NULL,                          /* no quoting function */
-  json_version_report         /* version reporting */
+  .name = US"json",                    /* lookup name */
+  .type = lookup_absfile,              /* uses absolute file name */
+  .open = json_open,                   /* open function */
+  .check = json_check,                 /* check function */
+  .find = json_find,                   /* find function */
+  .close = json_close,                 /* close function */
+  .tidy = NULL,                                /* no tidy function */
+  .quote = NULL,                       /* no quoting function */
+  .version_report = json_version_report         /* version reporting */
 };