Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Match the function prototype of encrypthandler instead of ca...



details:   https://anonhg.NetBSD.org/src/rev/da6e850b4d56
branches:  trunk
changeset: 447246:da6e850b4d56
user:      maya <maya%NetBSD.org@localhost>
date:      Sat Jan 05 08:55:58 2019 +0000

description:
Match the function prototype of encrypthandler instead of casting to it.
Make GCC 9 snapshot happier with the code

While here, remove unnecessary braces around return (KNF).

diffstat:

 lib/libtelnet/enc-proto.h |  16 ++++++------
 lib/libtelnet/encrypt.c   |  60 +++++++++++++++++++++++-----------------------
 usr.bin/telnet/commands.c |  28 ++++++++++-----------
 3 files changed, 51 insertions(+), 53 deletions(-)

diffs (256 lines):

diff -r 296df4b1203b -r da6e850b4d56 lib/libtelnet/enc-proto.h
--- a/lib/libtelnet/enc-proto.h Sat Jan 05 07:56:07 2019 +0000
+++ b/lib/libtelnet/enc-proto.h Sat Jan 05 08:55:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: enc-proto.h,v 1.9 2012/01/09 15:25:33 christos Exp $   */
+/*     $NetBSD: enc-proto.h,v 1.10 2019/01/05 08:55:58 maya Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -61,13 +61,13 @@
 int EncryptEnable(char *, char *);
 int EncryptDisable(char *, char *);
 int EncryptType(char *, char *);
-int EncryptStart(char *);
-int EncryptStartInput(void);
-int EncryptStartOutput(void);
-int EncryptStop(char *);
-int EncryptStopInput(void);
-int EncryptStopOutput(void);
-int EncryptStatus(void);
+int EncryptStart(char *, char *);
+int EncryptStartInput(char *, char *);
+int EncryptStartOutput(char *, char *);
+int EncryptStop(char *, char *);
+int EncryptStopInput(char *, char *);
+int EncryptStopOutput(char *, char *);
+int EncryptStatus(char *, char *);
 void encrypt_send_support(void);
 int EncryptDebug(int);
 int EncryptVerbose(int);
diff -r 296df4b1203b -r da6e850b4d56 lib/libtelnet/encrypt.c
--- a/lib/libtelnet/encrypt.c   Sat Jan 05 07:56:07 2019 +0000
+++ b/lib/libtelnet/encrypt.c   Sat Jan 05 08:55:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: encrypt.c,v 1.17 2012/03/21 05:33:27 matt Exp $        */
+/*     $NetBSD: encrypt.c,v 1.18 2019/01/05 08:55:58 maya Exp $        */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -33,7 +33,7 @@
 #if 0
 static char sccsid[] = "@(#)encrypt.c  8.2 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: encrypt.c,v 1.17 2012/03/21 05:33:27 matt Exp $");
+__RCSID("$NetBSD: encrypt.c,v 1.18 2019/01/05 08:55:58 maya Exp $");
 #endif /* not lint */
 
 /*
@@ -226,11 +226,11 @@
        if (isprefix(type, "help") || isprefix(type, "?")) {
                printf("Usage: encrypt enable <type> [input|output]\n");
                encrypt_list_types();
-               return(0);
+               return 0;
        }
        if (EncryptType(type, mode))
-               return(EncryptStart(mode));
-       return(0);
+               return EncryptStart(mode, NULL);
+       return 0;
 }
 
 int
@@ -250,13 +250,13 @@
        } else {
                if ((mode == 0) || (isprefix(mode, "input") ? 1 : 0)) {
                        if (decrypt_mode == ep->type)
-                               EncryptStopInput();
+                               EncryptStopInput(NULL, NULL);
                        i_wont_support_decrypt |= typemask(ep->type);
                        ret = 1;
                }
                if ((mode == 0) || (isprefix(mode, "output"))) {
                        if (encrypt_mode == ep->type)
-                               EncryptStopOutput();
+                               EncryptStopOutput(NULL, NULL);
                        i_wont_support_encrypt |= typemask(ep->type);
                        ret = 1;
                }
@@ -298,28 +298,28 @@
 }
 
 int
-EncryptStart(char *mode)
+EncryptStart(char *mode, char *unused __unused)
 {
        register int ret = 0;
        if (mode) {
                if (isprefix(mode, "input"))
-                       return(EncryptStartInput());
+                       return EncryptStartInput(NULL, NULL);
                if (isprefix(mode, "output"))
-                       return(EncryptStartOutput());
+                       return EncryptStartOutput(NULL, NULL);
                if (isprefix(mode, "help") || isprefix(mode, "?")) {
                        printf("Usage: encrypt start [input|output]\n");
-                       return(0);
+                       return 0;
                }
                printf("%s: invalid encryption mode 'encrypt start ?' for help\n", mode);
-               return(0);
+               return 0;
        }
-       ret += EncryptStartInput();
-       ret += EncryptStartOutput();
-       return(ret);
+       ret += EncryptStartInput(NULL, NULL);
+       ret += EncryptStartOutput(NULL, NULL);
+       return ret;
 }
 
 int
-EncryptStartInput(void)
+EncryptStartInput(char *unused1 __unused, char *unused2 __unused)
 {
        if (decrypt_mode) {
                encrypt_send_request_start();
@@ -330,7 +330,7 @@
 }
 
 int
-EncryptStartOutput(void)
+EncryptStartOutput(char *unused1 __unused, char *unused2 __unused)
 {
        if (encrypt_mode) {
                encrypt_start_output(encrypt_mode);
@@ -341,38 +341,38 @@
 }
 
 int
-EncryptStop(char *mode)
+EncryptStop(char *mode, char *unused __unused)
 {
        int ret = 0;
        if (mode) {
                if (isprefix(mode, "input"))
-                       return(EncryptStopInput());
+                       return EncryptStopInput(NULL, NULL);
                if (isprefix(mode, "output"))
-                       return(EncryptStopOutput());
+                       return EncryptStopOutput(NULL, NULL);
                if (isprefix(mode, "help") || isprefix(mode, "?")) {
                        printf("Usage: encrypt stop [input|output]\n");
-                       return(0);
+                       return 0;
                }
                printf("%s: invalid encryption mode 'encrypt stop ?' for help\n", mode);
-               return(0);
+               return 0;
        }
-       ret += EncryptStopInput();
-       ret += EncryptStopOutput();
-       return(ret);
+       ret += EncryptStopInput(NULL, NULL);
+       ret += EncryptStopOutput(NULL, NULL);
+       return ret;
 }
 
 int
-EncryptStopInput(void)
+EncryptStopInput(char *unused1 __unused, char *unused2 __unused)
 {
        encrypt_send_request_end();
-       return(1);
+       return 1;
 }
 
 int
-EncryptStopOutput(void)
+EncryptStopOutput(char *unused1 __unused, char *unused2 __unused)
 {
        encrypt_send_end();
-       return(1);
+       return 1;
 }
 
 void
@@ -387,7 +387,7 @@
 }
 
 int
-EncryptStatus(void)
+EncryptStatus(char *unused1 __unused, char *unused2 __unused)
 {
        if (encrypt_output)
                printf("Currently encrypting output with %s\r\n",
diff -r 296df4b1203b -r da6e850b4d56 usr.bin/telnet/commands.c
--- a/usr.bin/telnet/commands.c Sat Jan 05 07:56:07 2019 +0000
+++ b/usr.bin/telnet/commands.c Sat Jan 05 08:55:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: commands.c,v 1.75 2019/01/05 06:47:24 maya Exp $       */
+/*     $NetBSD: commands.c,v 1.76 2019/01/05 08:55:58 maya Exp $       */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: commands.c,v 1.75 2019/01/05 06:47:24 maya Exp $");
+__RCSID("$NetBSD: commands.c,v 1.76 2019/01/05 08:55:58 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -1280,7 +1280,7 @@
     }
 /*@*/optionstatus();
 #ifdef ENCRYPTION
-    EncryptStatus();
+    EncryptStatus(NULL, NULL);
 #endif /* ENCRYPTION */
     return 1;
 #undef doset
@@ -1888,9 +1888,7 @@
        int     maxarg;
 };
 
-static int
-       EncryptHelp(char *, char *);
-typedef int (*encrypthandler)(char *, char *);
+static int EncryptHelp(char *, char *);
 
 struct encryptlist EncryptList[] = {
     { "enable", "Enable encryption. ('encrypt enable ?' for more)",
@@ -1900,22 +1898,22 @@
     { "type", "Set encryption type. ('encrypt type ?' for more)",
                                                EncryptType, 0, 1, 1 },
     { "start", "Start encryption. ('encrypt start ?' for more)",
-                               (encrypthandler) EncryptStart, 1, 0, 1 },
+                                               EncryptStart, 1, 0, 1 },
     { "stop", "Stop encryption. ('encrypt stop ?' for more)",
-                               (encrypthandler) EncryptStop, 1, 0, 1 },
+                                               EncryptStop, 1, 0, 1 },
     { "input", "Start encrypting the input stream",
-                               (encrypthandler) EncryptStartInput, 1, 0, 0 },
+                                               EncryptStartInput, 1, 0, 0 },
     { "-input", "Stop encrypting the input stream",
-                               (encrypthandler) EncryptStopInput, 1, 0, 0 },
+                                               EncryptStopInput, 1, 0, 0 },
     { "output", "Start encrypting the output stream",
-                               (encrypthandler) EncryptStartOutput, 1, 0, 0 },
+                                               EncryptStartOutput, 1, 0, 0 },
     { "-output", "Stop encrypting the output stream",
-                               (encrypthandler) EncryptStopOutput, 1, 0, 0 },
+                                               EncryptStopOutput, 1, 0, 0 },
 
     { "status",       "Display current status of authentication information",
-                               (encrypthandler) EncryptStatus, 0, 0, 0 },
-    { "help", 0,                                EncryptHelp,   0, 0, 0 },
-    { "?",    "Print help information",                 EncryptHelp,   0, 0, 0 },
+                                               EncryptStatus,  0, 0, 0 },
+    { "help", 0,                               EncryptHelp,    0, 0, 0 },
+    { "?",    "Print help information",                EncryptHelp,    0, 0, 0 },
     { .name = 0 },
 };
 



Home | Main Index | Thread Index | Old Index