Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hp300/stand get rid of gets/tgets



details:   https://anonhg.NetBSD.org/src/rev/0c2cb60b8fc4
branches:  trunk
changeset: 345728:0c2cb60b8fc4
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Jun 05 17:43:02 2016 +0000

description:
get rid of gets/tgets

diffstat:

 sys/arch/hp300/stand/common/netio.c     |  12 ++++++------
 sys/arch/hp300/stand/common/samachdep.h |   4 ++--
 sys/arch/hp300/stand/common/tgets.c     |   9 +++++++--
 sys/arch/hp300/stand/uboot/uboot.c      |   4 ++--
 4 files changed, 17 insertions(+), 12 deletions(-)

diffs (119 lines):

diff -r e351f147f514 -r 0c2cb60b8fc4 sys/arch/hp300/stand/common/netio.c
--- a/sys/arch/hp300/stand/common/netio.c       Sun Jun 05 17:37:36 2016 +0000
+++ b/sys/arch/hp300/stand/common/netio.c       Sun Jun 05 17:43:02 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netio.c,v 1.14 2011/07/17 20:54:40 joerg Exp $ */
+/*     $NetBSD: netio.c,v 1.15 2016/06/05 17:43:02 christos Exp $      */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -169,7 +169,7 @@
  get_my_ip:
                printf("My IP address? ");
                memset(input_line, 0, sizeof(input_line));
-               gets(input_line);
+               gets_s(input_line, sizeof(input_line));
                if ((myip.s_addr = inet_addr(input_line)) ==
                    htonl(INADDR_NONE)) {
                        printf("invalid IP address: %s\n", input_line);
@@ -179,7 +179,7 @@
  get_my_netmask:
                printf("My netmask? ");
                memset(input_line, 0, sizeof(input_line)); 
-               gets(input_line);
+               gets_s(input_line, sizeof(input_line));
                if ((netmask = inet_addr(input_line)) ==
                    htonl(INADDR_NONE)) {
                        printf("invalid netmask: %s\n", input_line);
@@ -189,7 +189,7 @@
  get_my_gateway:
                printf("My gateway? ");
                memset(input_line, 0, sizeof(input_line)); 
-               gets(input_line);
+               gets_s(input_line, sizeof(input_line));
                if ((gateip.s_addr = inet_addr(input_line)) ==
                    htonl(INADDR_NONE)) {
                        printf("invalid IP address: %s\n", input_line);
@@ -199,7 +199,7 @@
  get_server_ip:
                printf("Server IP address? ");
                memset(input_line, 0, sizeof(input_line)); 
-               gets(input_line);
+               gets_s(input_line, sizeof(input_line));
                if ((rootip.s_addr = inet_addr(input_line)) ==
                    htonl(INADDR_NONE)) {
                        printf("invalid IP address: %s\n", input_line);
@@ -209,7 +209,7 @@
  get_server_path:
                printf("Server path? ");
                memset(rootpath, 0, sizeof(rootpath)); 
-               gets(rootpath);
+               gets_s(rootpath, sizeof(rootpath));
                if (rootpath[0] == '\0' || rootpath[0] == '\n')
                        goto get_server_path;
 
diff -r e351f147f514 -r 0c2cb60b8fc4 sys/arch/hp300/stand/common/samachdep.h
--- a/sys/arch/hp300/stand/common/samachdep.h   Sun Jun 05 17:37:36 2016 +0000
+++ b/sys/arch/hp300/stand/common/samachdep.h   Sun Jun 05 17:43:02 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: samachdep.h,v 1.18 2014/08/10 07:40:49 isaki Exp $     */
+/*     $NetBSD: samachdep.h,v 1.19 2016/06/05 17:43:02 christos Exp $  */
 
 /*
  * Copyright (c) 1982, 1990, 1993
@@ -98,7 +98,7 @@
 void _transfer(char *, int, int, int, char *, char *);
 
 /* tget.c */
-int tgets(char *);
+int tgets_s(char *, size_t);
 
 
 #define DELAY(n)                                                       \
diff -r e351f147f514 -r 0c2cb60b8fc4 sys/arch/hp300/stand/common/tgets.c
--- a/sys/arch/hp300/stand/common/tgets.c       Sun Jun 05 17:37:36 2016 +0000
+++ b/sys/arch/hp300/stand/common/tgets.c       Sun Jun 05 17:43:02 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tgets.c,v 1.5 2005/12/11 12:17:19 christos Exp $       */
+/*     $NetBSD: tgets.c,v 1.6 2016/06/05 17:43:02 christos Exp $       */
 
 /*-
  * Copyright (c) 1993
@@ -38,13 +38,18 @@
 #include <hp300/stand/common/samachdep.h>
 
 int
-tgets(char *buf)
+tgets_s(char *buf, size_t size)
 {
        int c;
        int i;
        char *lp = buf;
 
        for (i = 240000; i > 0; i--) {
+                if (lp - buf == size) {
+                        lp--;
+                        *lp = '\0';
+                        return; 
+                }
                c = tgetchar() & 0177;
                if (c) {
                        for (;;) {
diff -r e351f147f514 -r 0c2cb60b8fc4 sys/arch/hp300/stand/uboot/uboot.c
--- a/sys/arch/hp300/stand/uboot/uboot.c        Sun Jun 05 17:37:36 2016 +0000
+++ b/sys/arch/hp300/stand/uboot/uboot.c        Sun Jun 05 17:43:02 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uboot.c,v 1.15 2008/07/16 13:44:51 tsutsui Exp $       */
+/*     $NetBSD: uboot.c,v 1.16 2016/06/05 17:43:02 christos Exp $      */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -109,7 +109,7 @@
        printf("Boot: [[[%s%d%c:]%s][-a][-c][-d][-s][-v][-q]] :- ",
            devsw[bdev].dv_name, bctlr + (8 * badapt), 'a' + bpart, name);
 
-       if (tgets(line)) {
+       if (tgets_s(line, sizeof(line))) {
                if (strcmp(line, "reset") == 0) {
                        call_req_reboot();      /* reset machine */
                        printf("panic: can't reboot, halting\n");



Home | Main Index | Thread Index | Old Index