Fix clang 9 missing-field-initializer warnings
[amitay/samba.git] / source4 / lib / registry / tools / regdiff.c
index 8030457f5c72d2b930442fd045b87a3a3eaf62c8..b5cf4dd2566753c75db73c23f7ff4066c66a8025 100644 (file)
@@ -1,7 +1,7 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    simple registry frontend
-   
+
    Copyright (C) Jelmer Vernooij 2004-2007
    Copyright (C) Wilco Baan Hofman 2006
 
@@ -9,12 +9,12 @@
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "lib/events/events.h"
 #include "lib/cmdline/popt_common.h"
 #include "lib/registry/tools/common.h"
+#include "param/param.h"
 
 enum reg_backend { REG_UNKNOWN, REG_LOCAL, REG_REMOTE, REG_NULL };
 
-static struct registry_context *open_backend(poptContext pc, enum reg_backend backend, const char *remote_host)
+static struct registry_context *open_backend(TALLOC_CTX *mem_ctx,
+                                            poptContext pc,
+                                            struct tevent_context *ev_ctx,
+                                            struct loadparm_context *lp_ctx,
+                                            enum reg_backend backend,
+                                            const char *remote_host)
 {
        WERROR error;
        struct registry_context *ctx;
-       
+
        switch (backend) {
        case REG_UNKNOWN:
                poptPrintUsage(pc, stderr, 0);
                return NULL;
        case REG_LOCAL:
-               error = reg_open_samba(NULL, &ctx, NULL, cmdline_credentials);
+               error = reg_open_samba(mem_ctx, &ctx, ev_ctx, lp_ctx, NULL,
+                               popt_get_cmdline_credentials());
                break;
        case REG_REMOTE:
-               error = reg_open_remote(&ctx, NULL, cmdline_credentials, remote_host, NULL);
+               error = reg_open_remote(mem_ctx, &ctx, NULL,
+                               popt_get_cmdline_credentials(), lp_ctx,
+                                       remote_host, ev_ctx);
                break;
        case REG_NULL:
-               error = reg_open_local(NULL, &ctx, NULL, cmdline_credentials);
+               error = reg_open_local(mem_ctx, &ctx);
                break;
        }
 
@@ -73,10 +82,11 @@ int main(int argc, const char **argv)
                POPT_COMMON_SAMBA
                POPT_COMMON_CREDENTIALS
                POPT_COMMON_VERSION
-               { NULL }
+               {0}
        };
        TALLOC_CTX *ctx;
        void *callback_data;
+       struct tevent_context *ev_ctx;
        struct reg_diff_callbacks *callbacks;
 
        ctx = talloc_init("regdiff");
@@ -111,11 +121,13 @@ int main(int argc, const char **argv)
 
        }
 
-       h1 = open_backend(pc, backend1, remote1);
+       ev_ctx = s4_event_context_init(ctx);
+
+       h1 = open_backend(ctx, pc, ev_ctx, cmdline_lp_ctx, backend1, remote1);
        if (h1 == NULL)
                return 1;
 
-       h2 = open_backend(pc, backend2, remote2);
+       h2 = open_backend(ctx, pc, ev_ctx, cmdline_lp_ctx, backend2, remote2);
        if (h2 == NULL)
                return 1;
 
@@ -123,13 +135,15 @@ int main(int argc, const char **argv)
 
        error = reg_dotreg_diff_save(ctx, outputfile, &callbacks, &callback_data);
        if (!W_ERROR_IS_OK(error)) {
-               fprintf(stderr, "Problem saving registry diff to '%s': %s\n", outputfile, win_errstr(error));
+               fprintf(stderr, "Problem saving registry diff to '%s': %s\n",
+                       outputfile, win_errstr(error));
                return -1;
        }
 
        error = reg_generate_diff(h1, h2, callbacks, callback_data);
        if (!W_ERROR_IS_OK(error)) {
-               fprintf(stderr, "Unable to generate diff between keys: %s\n", win_errstr(error));
+               fprintf(stderr, "Unable to generate diff between keys: %s\n",
+                       win_errstr(error));
                return -1;
        }