]> git.samba.org - samba.git/commitdiff
examples/libsmbclient: avoid some compiler warnings
authorStefan Metzmacher <metze@samba.org>
Thu, 27 Feb 2014 08:39:20 +0000 (09:39 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 2 Apr 2014 07:03:42 +0000 (09:03 +0200)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
examples/libsmbclient/testacl2.c
examples/libsmbclient/testbrowse.c
examples/libsmbclient/testctx.c

index ef044f8a8dcaff0459b8a84fd8a3bf802f6c8179..a74a72d794c3fac235d567ac315457f32d158426 100644 (file)
@@ -25,6 +25,7 @@ int main(int argc, const char *argv[])
     int ret;
     const char *debugstr;
     char value[1024];
+    SMBCCTX *context;
 
     if (smbc_init(get_auth_data_fn, debug) != 0)
     {
@@ -32,7 +33,7 @@ int main(int argc, const char *argv[])
         return 1;
     }
 
-    SMBCCTX *context = smbc_set_context(NULL);
+    context = smbc_set_context(NULL);
     smbc_setOptionFullTimeNames(context, 1);
     
     the_acl = strdup("system.nt_sec_desc.*");
index 2ae7ca1c49a6f285d0f259ddadba05b9dc61688a..0629653ef8b0e5013fe3f9eab80174c3441039b1 100644 (file)
@@ -25,8 +25,7 @@ get_auth_data_with_context_fn(SMBCCTX * context,
                               char * pPassword,
                               int maxLenPassword);
 
-int
-main(int argc, char * argv[])
+int main(int argc, const char *argv[])
 {
     int                         debug = 0;
     int                         debug_stderr = 0;
@@ -73,7 +72,7 @@ main(int argc, char * argv[])
     
     setbuf(stdout, NULL);
 
-    pc = poptGetContext("opendir", argc, (const char **)argv, long_options, 0);
+    pc = poptGetContext("opendir", argc, argv, long_options, 0);
     
     poptSetOtherOptionHelp(pc, "");
     
@@ -100,7 +99,7 @@ main(int argc, char * argv[])
     if (context_auth) {
         smbc_setFunctionAuthDataWithContext(context,
                                             get_auth_data_with_context_fn);
-        smbc_setOptionUserData(context, (void *)"hello world");
+        smbc_setOptionUserData(context, strdup("hello world"));
     } else {
         smbc_setFunctionAuthData(context, get_auth_data_fn);
     }
@@ -126,20 +125,22 @@ main(int argc, char * argv[])
 
     if (scan)
     {
-        for (;
-             iterations == -1 || iterations > 0;
-             iterations = (iterations == -1 ? iterations : --iterations))
-        {
+        for (; iterations != 0;) {
+            if (iterations > 0) {
+                iterations--;
+            }
+
             snprintf(buf, sizeof(buf), "smb://");
             browse(buf, scan, 0);
         }
     }
     else
     {
-        for (;
-             iterations == -1 || iterations > 0;
-             iterations = (iterations == -1 ? iterations : --iterations))
-        {
+        for (; iterations != 0;) {
+            if (iterations > 0) {
+                iterations--;
+            }
+
             fputs("url: ", stdout);
             p = fgets(buf, sizeof(buf), stdin);
             if (! p)
index cec9776ced2445bf1cb64804df5281e755a091d1..7f27fbd7c9cfbdbe7c252f654de7d2cd0f42b44e 100644 (file)
@@ -1,15 +1,16 @@
 #include <libsmbclient.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 
-void create_and_destroy_context (void)
+static void create_and_destroy_context (void)
 {
   int i;
   SMBCCTX *ctx;
   ctx = smbc_new_context ();
   /* Both should do the same thing */
   smbc_setOptionDebugToStderr(ctx, 1);
-  smbc_option_set(ctx, "debug_to_stderr", 1);
+  smbc_option_set(ctx, strdup("debug_to_stderr"), 1);
   smbc_setDebug(ctx, 1);
   i = smbc_getDebug(ctx);
   if (i != 1) {