r7069: Add a little usage message to smbscript and fix a compiler warning. My
authorVolker Lendecke <vlendec@samba.org>
Sun, 29 May 2005 08:12:16 +0000 (08:12 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:11 +0000 (13:17 -0500)
compiler still complains about "handle" (scripting/ejs/smbscrip.c:46) possibly
not being initialized and to me this looks true.

Running smbscript with the trivial write("Hello, world\n"); also leaves some
memory around.

Volker

source/scripting/ejs/smbscript.c

index 0b0a4468398fc4b522062bc525758edeccce1a1e..57f42688d6be931aebd8932784dfc525abbcf9e5 100644 (file)
@@ -47,6 +47,11 @@ static int writeProc(MprVarHandle userHandle, int argc, char **argv)
        MprVar result;
        char *emsg;
 
+       if (argc != 2) {
+               fprintf(stderr, "Usage: %s <scriptfile>\n", argv[0]);
+               exit(1);
+       }
+
        if (ejsOpen(NULL, NULL, NULL) != 0) {
                fprintf(stderr, "smbscript: ejsOpen(): unable to initialise "
                        "EJ subsystem\n");
@@ -61,7 +66,8 @@ static int writeProc(MprVarHandle userHandle, int argc, char **argv)
                exit(1);
        }
 
-       if (ejsEvalFile(eid, (char *)argv[1], &result, &emsg) == -1) {
+       if (ejsEvalFile(eid, discard_const_p(char, argv[1]), &result,
+                       &emsg) == -1) {
                fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg);
                exit(1);
        }