lib/mime.c: Add a comment explaining the intentional `case' fall-through.
[disorder] / tests / udplog.c
index 81c0808..fe0b6ea 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder
- * Copyright (C) 2007 Richard Kettlewell
+ * Copyright (C) 2007-2009 Richard Kettlewell
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -49,7 +49,7 @@ static const struct option options[] = {
 };
 
 /* display usage message and terminate */
-static void help(void) {
+static void attribute((noreturn)) help(void) {
   xprintf("Usage:\n"
          "  disorder-udplog [OPTIONS] ADDRESS PORT\n"
          "Options:\n"
@@ -63,7 +63,7 @@ static void help(void) {
 }
 
 /* display version number and terminate */
-static void version(void) {
+static void attribute((noreturn)) version(void) {
   xprintf("%s", disorder_version_string);
   xfclose(stdout);
   exit(0);
@@ -134,12 +134,13 @@ int main(int argc, char **argv) {
       disorder_fatal(0, "getnameinfo: %s", gai_strerror(err));
     xprintf("from host %s service %s: %d bytes\n", h, s, n);
     for(i = 0; i < n; i += 16) {
-      for(j = i; j < n && j < i + 16; ++j)
+      const int limit = n > i + 16 ? i + 16 : n;
+      for(j = i; j < limit; ++j)
        xprintf(" %02x", buffer[j]);
       for(; j < i + 16; ++j)
        xprintf("   ");
       xprintf("  ");
-      for(j = i; j < n && j < i + 16; ++j)
+      for(j = i; j < limit; ++j)
        xprintf("%c", buffer[j] < 128 && isprint(buffer[j]) ? buffer[j] : '.');
       xprintf("\n");
       if(fflush(stdout) < 0)