$NetBSD: patch-ba,v 1.3 2011/09/19 07:15:52 dholland Exp $

- use modern C
- silence compiler warnings about assignments within if conditionals
- remove uses of implicit int to avoid warning noise
- use printf("%s", str) instead of printf(str)
- apply some const

--- server/args.c.orig	1998-03-27 15:11:58.000000000 +0000
+++ server/args.c
@@ -45,7 +45,7 @@
 
 #define USAGE	"usage: %s [:displaynum] [-option...]\n"
 
-static char *options[]	= {
+static const char *options[]	= {
        "-a #		ignored\n",
        "-af filename	read command line arguments from filename\n",
        "-auth path	select authorization file\n",
@@ -97,7 +97,7 @@ static char *options[]	= {
        "-wm		forces default backing store to WhenMapped\n",
        "-view disp...	the following displays may only watch\n",
        "-x extension	ignored\n",
-       (char *)0};
+       NULL};
 
 /*
 **	private data
@@ -420,7 +420,7 @@ args_get
       if (util_parse_display(hosts[i], &host, &family,
 					&display, &screen, &window)==0) {
          host_pattern(host);
-         if (name = host_match(&family, &length, &address))
+         if ((name = host_match(&family, &length, &address)) != NULL)
             (void) server_alloc(did++, name, strlen(name), family, length,
 			address, display, screen, modes[i], window, 0);
       }
@@ -432,17 +432,22 @@ args_get
 **
 **	Print usage message and options.
 */
+
+#ifdef __GNUC__
+static void usage(int) __attribute__((__noreturn__));
+#endif
+
 static void
 usage
    AL((status))
    DB int status
    DE
 {
-   register i;
+   register int i;
 
    fprintf(stderr, USAGE, command);
    for (i=0; options[i]; i++)
-      fprintf(stderr, options[i]);
+      fprintf(stderr, "%s", options[i]);
    exit(status);
 }
 
@@ -518,7 +523,7 @@ opt_str_arg
    char *rv;
 
    if (fp)
-      if (rv = tok(fp))
+      if ((rv = tok(fp)) != NULL)
          return rv;
       else {
          fclose(fp);
@@ -540,7 +545,7 @@ opt_debug_arg
 {
    int i, level;
    char *rv;
-   static char *debugopts[]	= {
+   static const char *debugopts[]	= {
        "1	trace incoming client X protocol\n",
        "2	trace outgoing virtual client X protocol\n",
        "3	trace incoming server X protocol\n",
@@ -573,7 +578,7 @@ opt_debug_arg
        "w	trace byte swapping operations\n",
        "x	trace XMC protocol\n",
        "?	print this message\n",
-       (char *)0};
+       NULL};
 
    if (fp && (rv = tok(fp)) == 0) {
       fclose(fp);
@@ -621,7 +626,7 @@ opt_debug_arg
             case '?':
                fprintf(stderr, "debug options:\n");
                for (i=0; debugopts[i]; i++)
-                  fprintf(stderr, debugopts[i]);
+                  fprintf(stderr, "%s", debugopts[i]);
                exit(0);
             default:
                warn("unknown debug option '%c'\n", *rv);
@@ -686,6 +691,9 @@ tok
                buf[i++] = (char)ch;
             break;
       }
-   return (char *)err(0, "tok: token too long\n");
+   /* this err() returns its first arg */
+   /*return (char *)err(0, "tok: token too long\n");*/
+   err(0, "tok: token too long\n");
+   return NULL;
 }
 #undef MAXTOKLEN
