CVS commit: src/usr.sbin/memswitch
Module Name:src Committed By: isaki Date: Fri Feb 8 08:55:35 UTC 2019 Modified Files: src/usr.sbin/memswitch: Makefile memswitch.c Log Message: Rewrite modify_single() to make compilable on gcc7. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/memswitch/Makefile cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/memswitch/memswitch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/memswitch/Makefile diff -u src/usr.sbin/memswitch/Makefile:1.2 src/usr.sbin/memswitch/Makefile:1.3 --- src/usr.sbin/memswitch/Makefile:1.2 Thu Feb 7 06:01:04 2019 +++ src/usr.sbin/memswitch/Makefile Fri Feb 8 08:55:35 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2019/02/07 06:01:04 mrg Exp $ +# $NetBSD: Makefile,v 1.3 2019/02/08 08:55:35 isaki Exp $ .if ${MACHINE} == "x68k" PROG= memswitch @@ -8,11 +8,4 @@ SRCS= memswitch.c properties.c methods.c MAN= memswitch.8 MANSUBDIR= /x68k -.include - -# XXX Not sure how to fix this problem -.if defined(HAVE_GCC) && ${HAVE_GCC} == 7 && ${ACTIVE_CC} == "gcc" -COPTS.memswitch.c+= -Wno-error=stringop-overflow -.endif - .include Index: src/usr.sbin/memswitch/memswitch.c diff -u src/usr.sbin/memswitch/memswitch.c:1.16 src/usr.sbin/memswitch/memswitch.c:1.17 --- src/usr.sbin/memswitch/memswitch.c:1.16 Fri Feb 8 08:41:11 2019 +++ src/usr.sbin/memswitch/memswitch.c Fri Feb 8 08:55:35 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: memswitch.c,v 1.16 2019/02/08 08:41:11 isaki Exp $ */ +/* $NetBSD: memswitch.c,v 1.17 2019/02/08 08:55:35 isaki Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -196,41 +196,37 @@ show_all(void) void modify_single(const char *expr) { - int i, l, n; - char *class = NULL, *node = NULL; + int i; + char *buf; + char *p; + const char *class; + const char *node; const char *value; char valuestr[MAXVALUELEN]; - l = 0; - n = strlen(expr); - for (i = 0; i < n; i++) { - if (expr[i] == '.') { - l = i + 1; - class = alloca(l); - if (class == 0) -err(1, "alloca"); - strncpy(class, expr, i); - class[i] = 0; + buf = strdup(expr); + if (buf == NULL) + err(EXIT_FAILURE, "strdup failed"); + + p = buf; + for (class = p; *p; p++) { + if (*p == '.') { + *p++ = '\0'; break; } } - if (i >= n) - errx(1, "Invalid expression: %s", expr); - for ( ; i < n; i++) { - if (expr[i] == '=') { - node = alloca(i - l + 1); - if (node == 0) -err(1, "alloca"); - strncpy(node, &(expr[l]), i - l); - node[i - l] = 0; + for (node = p; *p; p++) { + if (*p == '=') { + *p++ = '\0'; break; } } - if (i >= n) - errx(1, "Invalid expression: %s", expr); - value = &(expr[++i]); + value = p; + + if (class[0] == '\0' || node[0] == '\0' || value[0] == '\0') + errx(1, "Invalid expression: %s", expr); for (i = 0; i < number_of_props; i++) { if (strcmp(properties[i].class, class) == 0 && @@ -248,7 +244,7 @@ modify_single(const char *expr) errx(1, "No such property: %s.%s", class, node); } - return; + free(buf); } void
CVS commit: src/usr.sbin/memswitch
Module Name:src Committed By: isaki Date: Fri Feb 8 08:41:11 UTC 2019 Modified Files: src/usr.sbin/memswitch: memswitch.c Log Message: Make compilable even SRAMDEBUG. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/memswitch/memswitch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/memswitch/memswitch.c diff -u src/usr.sbin/memswitch/memswitch.c:1.15 src/usr.sbin/memswitch/memswitch.c:1.16 --- src/usr.sbin/memswitch/memswitch.c:1.15 Fri Jan 26 09:38:26 2018 +++ src/usr.sbin/memswitch/memswitch.c Fri Feb 8 08:41:11 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: memswitch.c,v 1.15 2018/01/26 09:38:26 christos Exp $ */ +/* $NetBSD: memswitch.c,v 1.16 2019/02/08 08:41:11 isaki Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -48,6 +48,7 @@ * SRAMDEBUG -- works on other (faster) platforms; * store in a regular file instead of actual non-volatile static RAM. */ +#include #define PATH_RAMFILE "/tmp/sramfile" #endif
CVS commit: src/usr.sbin/memswitch
Module Name:src Committed By: mrg Date: Thu Feb 7 06:01:04 UTC 2019 Modified Files: src/usr.sbin/memswitch: Makefile Log Message: disable stringop-overflow warning for GCC 7. triggers here and seems impossible on current netbsd given it's takling about argv > 2GB, and this is only for x68k anyway. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 src/usr.sbin/memswitch/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/memswitch/Makefile diff -u src/usr.sbin/memswitch/Makefile:1.1.1.1 src/usr.sbin/memswitch/Makefile:1.2 --- src/usr.sbin/memswitch/Makefile:1.1.1.1 Mon Jun 21 15:56:03 1999 +++ src/usr.sbin/memswitch/Makefile Thu Feb 7 06:01:04 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1.1.1 1999/06/21 15:56:03 minoura Exp $ +# $NetBSD: Makefile,v 1.2 2019/02/07 06:01:04 mrg Exp $ .if ${MACHINE} == "x68k" PROG= memswitch @@ -8,4 +8,11 @@ SRCS= memswitch.c properties.c methods.c MAN= memswitch.8 MANSUBDIR= /x68k +.include + +# XXX Not sure how to fix this problem +.if defined(HAVE_GCC) && ${HAVE_GCC} == 7 && ${ACTIVE_CC} == "gcc" +COPTS.memswitch.c+= -Wno-error=stringop-overflow +.endif + .include
CVS commit: src/usr.sbin/memswitch
Module Name:src Committed By: christos Date: Fri Jan 26 09:38:26 UTC 2018 Modified Files: src/usr.sbin/memswitch: memswitch.c memswitch.h Log Message: make this build again. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/memswitch/memswitch.c cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/memswitch/memswitch.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/memswitch/memswitch.c diff -u src/usr.sbin/memswitch/memswitch.c:1.14 src/usr.sbin/memswitch/memswitch.c:1.15 --- src/usr.sbin/memswitch/memswitch.c:1.14 Tue Jan 23 17:40:06 2018 +++ src/usr.sbin/memswitch/memswitch.c Fri Jan 26 04:38:26 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: memswitch.c,v 1.14 2018/01/23 22:40:06 sevan Exp $ */ +/* $NetBSD: memswitch.c,v 1.15 2018/01/26 09:38:26 christos Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -41,11 +41,11 @@ #include -#ifndef DEBUG +#ifndef SRAMDEBUG #include #else /* - * DEBUG -- works on other (faster) platforms; + * SRAMDEBUG -- works on other (faster) platforms; * store in a regular file instead of actual non-volatile static RAM. */ #define PATH_RAMFILE "/tmp/sramfile" @@ -290,7 +290,7 @@ alloc_modified_values(void) void alloc_current_values(void) { -#ifndef DEBUG +#ifndef SRAMDEBUG int i; int sramfd = 0; struct sram_io buffer; @@ -367,7 +367,7 @@ flush(void) { int i; int sramfd = 0; -#ifndef DEBUG +#ifndef SRAMDEBUG struct sram_io buffer; #endif @@ -380,7 +380,7 @@ flush(void) /* Not modified at all. */ return; -#ifndef DEBUG +#ifndef SRAMDEBUG /* Assume SRAM_IO_SIZE = n * 16. */ for (i = 0; i < 256; i += SRAM_IO_SIZE) { if (memcmp(_values[i], _values[i], @@ -414,7 +414,7 @@ flush(void) int save(const char *name) { -#ifndef DEBUG +#ifndef SRAMDEBUG int fd; alloc_current_values(); @@ -442,7 +442,7 @@ save(const char *name) int restore(const char *name) { -#ifndef DEBUG +#ifndef SRAMDEBUG int sramfd, fd, i; struct sram_io buffer; Index: src/usr.sbin/memswitch/memswitch.h diff -u src/usr.sbin/memswitch/memswitch.h:1.4 src/usr.sbin/memswitch/memswitch.h:1.5 --- src/usr.sbin/memswitch/memswitch.h:1.4 Wed Jan 24 09:45:44 2018 +++ src/usr.sbin/memswitch/memswitch.h Fri Jan 26 04:38:26 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: memswitch.h,v 1.4 2018/01/24 14:45:44 sevan Exp $ */ +/* $NetBSD: memswitch.h,v 1.5 2018/01/26 09:38:26 christos Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -79,13 +79,12 @@ extern char *progname; extern u_int8_t *current_values; extern u_int8_t *modified_values; -static void usage(void) __dead; -void show_single(const char*)); -void show_all(void)); -void modify_single(const char*)); -void help_single(const char*)); -void alloc_current_values(void)); -void alloc_modified_values(void)); -void flush(void)); -int save(const char*)); -int restore(const char*)); +void show_single(const char*); +void show_all(void); +void modify_single(const char*); +void help_single(const char*); +void alloc_current_values(void); +void alloc_modified_values(void); +void flush(void); +int save(const char*); +int restore(const char*);
CVS commit: src/usr.sbin/memswitch
Module Name:src Committed By: sevan Date: Wed Jan 24 14:45:44 UTC 2018 Modified Files: src/usr.sbin/memswitch: memswitch.h Log Message: typo, remove extra bracket To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/memswitch/memswitch.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/memswitch/memswitch.h diff -u src/usr.sbin/memswitch/memswitch.h:1.3 src/usr.sbin/memswitch/memswitch.h:1.4 --- src/usr.sbin/memswitch/memswitch.h:1.3 Tue Jan 23 21:06:25 2018 +++ src/usr.sbin/memswitch/memswitch.h Wed Jan 24 14:45:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: memswitch.h,v 1.3 2018/01/23 21:06:25 sevan Exp $ */ +/* $NetBSD: memswitch.h,v 1.4 2018/01/24 14:45:44 sevan Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -79,7 +79,7 @@ extern char *progname; extern u_int8_t *current_values; extern u_int8_t *modified_values; -static void usage(void)) __dead; +static void usage(void) __dead; void show_single(const char*)); void show_all(void)); void modify_single(const char*));
CVS commit: src/usr.sbin/memswitch
Module Name:src Committed By: sevan Date: Tue Jan 23 22:40:06 UTC 2018 Modified Files: src/usr.sbin/memswitch: memswitch.c Log Message: Restore rcstag. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/memswitch/memswitch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/memswitch/memswitch.c diff -u src/usr.sbin/memswitch/memswitch.c:1.13 src/usr.sbin/memswitch/memswitch.c:1.14 --- src/usr.sbin/memswitch/memswitch.c:1.13 Tue Jan 23 21:06:25 2018 +++ src/usr.sbin/memswitch/memswitch.c Tue Jan 23 22:40:06 2018 @@ -1,4 +1,4 @@ - +/* $NetBSD: memswitch.c,v 1.14 2018/01/23 22:40:06 sevan Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc.
CVS commit: src/usr.sbin/memswitch
Module Name:src Committed By: isaki Date: Mon Sep 21 08:04:43 UTC 2015 Modified Files: src/usr.sbin/memswitch: properties.c Log Message: Fix typo. display.contrast is 0-15, not 0-1. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/memswitch/properties.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/memswitch/properties.c diff -u src/usr.sbin/memswitch/properties.c:1.4 src/usr.sbin/memswitch/properties.c:1.5 --- src/usr.sbin/memswitch/properties.c:1.4 Mon Apr 28 20:24:17 2008 +++ src/usr.sbin/memswitch/properties.c Mon Sep 21 08:04:43 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: properties.c,v 1.4 2008/04/28 20:24:17 martin Exp $ */ +/* $NetBSD: properties.c,v 1.5 2015/09/21 08:04:43 isaki Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -120,7 +120,7 @@ struct property properties[] = { { "display", "contrast", 40, 1, 0, {byte:{[0] 0}}, 0, {byte:{[0] 0}}, {byte:{[0] 14}}, - parse_uchar, 0, 1, + parse_uchar, 0, 15, print_uchar, fill_uchar, flush_uchar, " Display contrast (0-15).\n"
CVS commit: src/usr.sbin/memswitch
Module Name:src Committed By: minoura Date: Fri Jan 14 13:25:16 UTC 2011 Modified Files: src/usr.sbin/memswitch: memswitch.c Log Message: Fix restore() (-r option). It didn't read the input file. Apparently I did not test that code. Pointed out by wiz@, thanks. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/memswitch/memswitch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/memswitch/memswitch.c diff -u src/usr.sbin/memswitch/memswitch.c:1.10 src/usr.sbin/memswitch/memswitch.c:1.11 --- src/usr.sbin/memswitch/memswitch.c:1.10 Mon Apr 28 20:24:16 2008 +++ src/usr.sbin/memswitch/memswitch.c Fri Jan 14 13:25:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: memswitch.c,v 1.10 2008/04/28 20:24:16 martin Exp $ */ +/* $NetBSD: memswitch.c,v 1.11 2011/01/14 13:25:16 minoura Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -467,7 +467,13 @@ err (1, Opening input file); } - sramfd = open (_PATH_DEVSRAM, O_RDONLY); + if (read (fd, modified_values, 256) != 256) + err (1, Reading input file); + + if (fd != 0) + close (fd); + + sramfd = open (_PATH_DEVSRAM, O_RDWR); if (sramfd 0) err (1, Opening %s, _PATH_DEVSRAM);
CVS commit: src/usr.sbin/memswitch
Module Name:src Committed By: minoura Date: Fri Jan 14 13:31:48 UTC 2011 Modified Files: src/usr.sbin/memswitch: memswitch.c methods.c Log Message: Whitespace. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/memswitch/memswitch.c cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/memswitch/methods.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/memswitch/memswitch.c diff -u src/usr.sbin/memswitch/memswitch.c:1.11 src/usr.sbin/memswitch/memswitch.c:1.12 --- src/usr.sbin/memswitch/memswitch.c:1.11 Fri Jan 14 13:25:16 2011 +++ src/usr.sbin/memswitch/memswitch.c Fri Jan 14 13:31:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: memswitch.c,v 1.11 2011/01/14 13:25:16 minoura Exp $ */ +/* $NetBSD: memswitch.c,v 1.12 2011/01/14 13:31:47 minoura Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -63,10 +63,10 @@ void usage(void) { - fprintf (stderr, usage: %s -a\n, progname); - fprintf (stderr,%s [-h] variable ...\n, progname); - fprintf (stderr,%s -w variable=value ...\n, progname); - fprintf (stderr,%s [-rs] filename\n, progname); + fprintf(stderr, usage: %s -a\n, progname); + fprintf(stderr,%s [-h] variable ...\n, progname); + fprintf(stderr,%s -w variable=value ...\n, progname); + fprintf(stderr,%s [-rs] filename\n, progname); exit(1); } @@ -112,7 +112,7 @@ if (argc == 0) usage(); while (argv[0]) { - show_single (argv[0]); + show_single(argv[0]); argv++; } break; @@ -128,13 +128,13 @@ modify_single (argv[0]); argv++; } - flush (); + flush(); break; case MD_HELP: if (argc == 0) usage(); while (argv[0]) { - help_single (argv[0]); + help_single(argv[0]); argv++; } break; @@ -165,16 +165,16 @@ for (i = 0; i number_of_props; i++) { snprintf(fullname, sizeof(fullname), %s.%s, - properties[i].class, properties[i].node); + properties[i].class, properties[i].node); if (strcmp(name, fullname) == 0 || strcmp(name, properties[i].class) == 0) { - properties[i].print (properties[i], valuestr); + properties[i].print(properties[i], valuestr); if (!nflag) -printf (%s=%s\n, fullname, valuestr); +printf(%s=%s\n, fullname, valuestr); n++; } } if (n == 0) { - errx (1, No such %s: %s, strstr(name, .)?property:class, name); + errx(1, No such %s: %s, strstr(name, .)?property:class, name); } return; @@ -187,11 +187,11 @@ char valuestr[MAXVALUELEN]; for (i = 0; i number_of_props; i++) { - properties[i].print (properties[i], valuestr); + properties[i].print(properties[i], valuestr); if (!nflag) - printf (%s.%s=, -properties[i].class, properties[i].node); - printf (%s\n, valuestr); + printf(%s.%s=, + properties[i].class, properties[i].node); + printf(%s\n, valuestr); } return; @@ -213,27 +213,27 @@ l = i + 1; class = alloca(l); if (class == 0) -err (1, alloca); - strncpy (class, expr, i); +err(1, alloca); + strncpy(class, expr, i); class[i] = 0; break; } } if (i = n) - errx (1, Invalid expression: %s, expr); + errx(1, Invalid expression: %s, expr); for ( ; i n; i++) { if (expr[i] == '=') { node = alloca(i - l + 1); if (node == 0) -err (1, alloca); - strncpy (node, (expr[l]), i - l); +err(1, alloca); + strncpy(node, (expr[l]), i - l); node[i - l] = 0; break; } } if (i = n) - errx (1, Invalid expression: %s, expr); + errx(1, Invalid expression: %s, expr); value = (expr[++i]); @@ -243,14 +243,14 @@ if (properties[i].parse(properties[i], value) 0) { /* error: do nothing */ } else { -properties[i].print (properties[i], valuestr); +properties[i].print(properties[i], valuestr); printf(%s.%s - %s\n, class, node, valuestr); } break; } } if (i = number_of_props) { - errx (1, No such property: %s.%s, class, node); + errx(1, No such property: %s.%s, class, node); } return; @@ -268,16 +268,16 @@ snprintf(fullname, sizeof(fullname), %s.%s, properties[i].class, properties[i].node); if (strcmp(name, fullname) == 0) { - properties[i].print (properties[i], valuestr); + properties[i].print(properties[i], valuestr); if (!nflag) -printf (%s=, fullname); - printf (%s\n, valuestr); - printf (%s, properties[i].descr); +printf(%s=, fullname); + printf(%s\n, valuestr); + printf(%s, properties[i].descr); break; } } if (i = number_of_props) { - errx (1, No such property: %s, name); + errx(1, No such property: %s, name); } return; @@ -288,10 +288,10 @@ { if (current_values == 0) alloc_current_values(); - modified_values = malloc (256); + modified_values = malloc(256); if (modified_values == 0) - err (1, malloc); - memcpy (modified_values, current_values, 256); + err(1, malloc); + memcpy(modified_values,