Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/wsconsctl Style fixes:
details: https://anonhg.NetBSD.org/src/rev/745c67802843
branches: trunk
changeset: 588041:745c67802843
user: jmmv <jmmv%NetBSD.org@localhost>
date: Sun Feb 05 18:11:46 2006 +0000
description:
Style fixes:
- Use EXIT_SUCCESS/EXIT_FAILURE where appropriate.
- Cut long lines.
- Properly indent continuation of lines.
- Sort includes.
- Replace u_int with unsigned int.
- Remove parenthesis around return values.
- Add blank line at the beginning of functions without local parameters.
- Cast *printf calls to void.
diffstat:
sbin/wsconsctl/display.c | 49 ++++++++-------
sbin/wsconsctl/keyboard.c | 62 +++++++++++--------
sbin/wsconsctl/keysym.c | 41 +++++++-----
sbin/wsconsctl/map_parse.y | 13 ++-
sbin/wsconsctl/map_scan.l | 14 +++-
sbin/wsconsctl/mouse.c | 23 +++---
sbin/wsconsctl/util.c | 140 +++++++++++++++++++++++---------------------
sbin/wsconsctl/wsconsctl.c | 47 ++++++++------
8 files changed, 215 insertions(+), 174 deletions(-)
diffs (truncated from 1127 to 300 lines):
diff -r 8513aeac0de1 -r 745c67802843 sbin/wsconsctl/display.c
--- a/sbin/wsconsctl/display.c Sun Feb 05 18:10:57 2006 +0000
+++ b/sbin/wsconsctl/display.c Sun Feb 05 18:11:46 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: display.c,v 1.11 2005/04/30 16:38:21 jmmv Exp $ */
+/* $NetBSD: display.c,v 1.12 2006/02/05 18:11:46 jmmv Exp $ */
/*-
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -39,12 +39,13 @@
#include <sys/ioctl.h>
#include <sys/time.h>
-#include <stdio.h>
-#include <string.h>
+#include <dev/wscons/wsconsio.h>
+
+#include <err.h>
#include <errno.h>
-#include <err.h>
-
-#include <dev/wscons/wsconsio.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include "wsconsctl.h"
@@ -65,8 +66,8 @@
{ "backlight", &backlight.curval, FMT_UINT, 0 },
{ "brightness", &brightness.curval, FMT_UINT, FLG_MODIFY },
{ "contrast", &contrast.curval, FMT_UINT, FLG_MODIFY },
- { "scroll.fastlines", &scroll_l.fastlines, FMT_UINT, FLG_MODIFY },
- { "scroll.slowlines", &scroll_l.slowlines, FMT_UINT, FLG_MODIFY },
+ { "scroll.fastlines", &scroll_l.fastlines, FMT_UINT, FLG_MODIFY },
+ { "scroll.slowlines", &scroll_l.slowlines, FMT_UINT, FLG_MODIFY },
{ "msg.default.attrs", &msg_default_attrs, FMT_ATTRS, 0 },
{ "msg.default.bg", &msg_default_bg, FMT_COLOR, 0 },
{ "msg.default.fg", &msg_default_fg, FMT_COLOR, 0 },
@@ -75,15 +76,16 @@
{ "msg.kernel.fg", &msg_kernel_fg, FMT_COLOR, 0 },
};
-int display_field_tab_len = sizeof(display_field_tab)/
- sizeof(display_field_tab[0]);
+int display_field_tab_len = sizeof(display_field_tab) /
+ sizeof(display_field_tab[0]);
void
display_get_values(int fd)
{
+
if (field_by_value(&dpytype)->flags & FLG_GET)
if (ioctl(fd, WSDISPLAYIO_GTYPE, &dpytype) < 0)
- err(1, "WSDISPLAYIO_GTYPE");
+ err(EXIT_FAILURE, "WSDISPLAYIO_GTYPE");
if (field_by_value(&border)->flags & FLG_GET)
if (ioctl(fd, WSDISPLAYIO_GBORDER, &border) < 0)
@@ -152,36 +154,37 @@
display_put_values(fd)
int fd;
{
+
if (field_by_value(&font.name)->flags & FLG_SET) {
if (ioctl(fd, WSDISPLAYIO_SFONT, &font) < 0)
- err(1, "WSDISPLAYIO_SFONT");
+ err(EXIT_FAILURE, "WSDISPLAYIO_SFONT");
pr_field(field_by_value(&font.name), " -> ");
}
if (field_by_value(&border)->flags & FLG_SET) {
if (ioctl(fd, WSDISPLAYIO_SBORDER, &border) < 0)
- err(1, "WSDISPLAYIO_SBORDER");
+ err(EXIT_FAILURE, "WSDISPLAYIO_SBORDER");
pr_field(field_by_value(&border), " -> ");
}
if (field_by_value(&backlight.curval)->flags & FLG_SET) {
backlight.param = WSDISPLAYIO_PARAM_BACKLIGHT;
if (ioctl(fd, WSDISPLAYIO_SETPARAM, &backlight) < 0)
- err(1, "WSDISPLAYIO_PARAM_BACKLIGHT");
+ err(EXIT_FAILURE, "WSDISPLAYIO_PARAM_BACKLIGHT");
pr_field(field_by_value(&backlight.curval), " -> ");
}
if (field_by_value(&brightness.curval)->flags & FLG_SET) {
brightness.param = WSDISPLAYIO_PARAM_BRIGHTNESS;
if (ioctl(fd, WSDISPLAYIO_SETPARAM, &brightness) < 0)
- err(1, "WSDISPLAYIO_PARAM_BRIGHTNESS");
+ err(EXIT_FAILURE, "WSDISPLAYIO_PARAM_BRIGHTNESS");
pr_field(field_by_value(&brightness.curval), " -> ");
}
if (field_by_value(&contrast.curval)->flags & FLG_SET) {
contrast.param = WSDISPLAYIO_PARAM_CONTRAST;
if (ioctl(fd, WSDISPLAYIO_SETPARAM, &contrast) < 0)
- err(1, "WSDISPLAYIO_PARAM_CONTRAST");
+ err(EXIT_FAILURE, "WSDISPLAYIO_PARAM_CONTRAST");
pr_field(field_by_value(&contrast.curval), " -> ");
}
@@ -194,7 +197,7 @@
struct wsdisplay_msgattrs ma;
if (ioctl(fd, WSDISPLAYIO_GMSGATTRS, &ma) < 0)
- err(1, "WSDISPLAYIO_GMSGATTRS");
+ err(EXIT_FAILURE, "WSDISPLAYIO_GMSGATTRS");
if (field_by_value(&msg_default_attrs)->flags & FLG_SET) {
ma.default_attrs = msg_default_attrs;
@@ -204,12 +207,12 @@
if (field_by_value(&msg_default_bg)->flags & FLG_SET) {
ma.default_bg = msg_default_bg;
pr_field(field_by_value(&msg_default_bg),
- " -> ");
+ " -> ");
}
if (field_by_value(&msg_default_fg)->flags & FLG_SET) {
ma.default_fg = msg_default_fg;
pr_field(field_by_value(&msg_default_fg),
- " -> ");
+ " -> ");
}
}
@@ -221,17 +224,17 @@
if (field_by_value(&msg_kernel_bg)->flags & FLG_SET) {
ma.kernel_bg = msg_kernel_bg;
pr_field(field_by_value(&msg_kernel_bg),
- " -> ");
+ " -> ");
}
if (field_by_value(&msg_kernel_fg)->flags & FLG_SET) {
ma.kernel_fg = msg_kernel_fg;
pr_field(field_by_value(&msg_kernel_fg),
- " -> ");
+ " -> ");
}
}
if (ioctl(fd, WSDISPLAYIO_SMSGATTRS, &ma) < 0)
- err(1, "WSDISPLAYIO_SMSGATTRS");
+ err(EXIT_FAILURE, "WSDISPLAYIO_SMSGATTRS");
}
scroll_l.which = 0;
@@ -241,7 +244,7 @@
scroll_l.which |= WSDISPLAY_SCROLL_DOSLOWLINES;
if (scroll_l.which != 0 &&
ioctl(fd, WSDISPLAYIO_DSSCROLL, &scroll_l) < 0)
- err (1, "WSDISPLAYIO_DSSCROLL");
+ err(EXIT_FAILURE, "WSDISPLAYIO_DSSCROLL");
if (scroll_l.which & WSDISPLAY_SCROLL_DOFASTLINES)
pr_field(field_by_value(&scroll_l.fastlines), " -> ");
if (scroll_l.which & WSDISPLAY_SCROLL_DOSLOWLINES)
diff -r 8513aeac0de1 -r 745c67802843 sbin/wsconsctl/keyboard.c
--- a/sbin/wsconsctl/keyboard.c Sun Feb 05 18:10:57 2006 +0000
+++ b/sbin/wsconsctl/keyboard.c Sun Feb 05 18:11:46 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: keyboard.c,v 1.7 2005/01/19 20:37:52 xtraeme Exp $ */
+/* $NetBSD: keyboard.c,v 1.8 2006/02/05 18:11:46 jmmv Exp $ */
/*-
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -38,10 +38,14 @@
#include <sys/ioctl.h>
#include <sys/time.h>
+
#include <dev/wscons/wsksymdef.h>
#include <dev/wscons/wsconsio.h>
+
#include <err.h>
#include <errno.h>
+#include <stdlib.h>
+
#include "wsconsctl.h"
static int kbtype;
@@ -49,8 +53,8 @@
static struct wskbd_bell_data bell;
static struct wskbd_bell_data dfbell;
static struct wscons_keymap mapdata[KS_NUMKEYCODES];
-struct wskbd_map_data kbmap = { KS_NUMKEYCODES, mapdata }; /* used in map_parse.y
- and in util.c */
+struct wskbd_map_data kbmap = /* used in map_parse.y and in util.c */
+ { KS_NUMKEYCODES, mapdata };
static struct wskbd_keyrepeat_data repeat;
static struct wskbd_keyrepeat_data dfrepeat;
static struct wskbd_scroll_data scroll;
@@ -66,7 +70,8 @@
{ "bell.pitch.default", &dfbell.pitch, FMT_UINT, FLG_MODIFY },
{ "bell.period.default", &dfbell.period, FMT_UINT, FLG_MODIFY },
{ "bell.volume.default", &dfbell.volume, FMT_UINT, FLG_MODIFY },
- { "map", &kbmap, FMT_KBMAP, FLG_MODIFY|FLG_NOAUTO },
+ { "map", &kbmap, FMT_KBMAP, FLG_MODIFY |
+ FLG_NOAUTO },
{ "repeat.del1", &repeat.del1, FMT_UINT, FLG_MODIFY },
{ "repeat.deln", &repeat.delN, FMT_UINT, FLG_MODIFY },
{ "repeat.del1.default", &dfrepeat.del1, FMT_UINT, FLG_MODIFY },
@@ -74,19 +79,20 @@
{ "ledstate", &ledstate, FMT_UINT, 0 },
{ "encoding", &kbdencoding, FMT_KBDENC, FLG_MODIFY },
{ "keyclick", &keyclick, FMT_UINT, FLG_MODIFY },
- { "scroll.mode", &scroll.mode, FMT_UINT, FLG_MODIFY },
- { "scroll.modifier", &scroll.modifier, FMT_UINT, FLG_MODIFY },
+ { "scroll.mode", &scroll.mode, FMT_UINT, FLG_MODIFY },
+ { "scroll.modifier", &scroll.modifier, FMT_UINT, FLG_MODIFY },
};
-int keyboard_field_tab_len = sizeof(keyboard_field_tab)/
- sizeof(keyboard_field_tab[0]);
+int keyboard_field_tab_len = sizeof(keyboard_field_tab) /
+ sizeof(keyboard_field_tab[0]);
void
keyboard_get_values(int fd)
{
+
if (field_by_value(&kbtype)->flags & FLG_GET)
if (ioctl(fd, WSKBDIO_GTYPE, &kbtype) < 0)
- err(1, "WSKBDIO_GTYPE");
+ err(EXIT_FAILURE, "WSKBDIO_GTYPE");
bell.which = 0;
if (field_by_value(&bell.pitch)->flags & FLG_GET)
@@ -96,7 +102,7 @@
if (field_by_value(&bell.volume)->flags & FLG_GET)
bell.which |= WSKBD_BELL_DOVOLUME;
if (bell.which != 0 && ioctl(fd, WSKBDIO_GETBELL, &bell) < 0)
- err(1, "WSKBDIO_GETBELL");
+ err(EXIT_FAILURE, "WSKBDIO_GETBELL");
dfbell.which = 0;
if (field_by_value(&dfbell.pitch)->flags & FLG_GET)
@@ -107,12 +113,12 @@
dfbell.which |= WSKBD_BELL_DOVOLUME;
if (dfbell.which != 0 &&
ioctl(fd, WSKBDIO_GETDEFAULTBELL, &dfbell) < 0)
- err(1, "WSKBDIO_GETDEFAULTBELL");
+ err(EXIT_FAILURE, "WSKBDIO_GETDEFAULTBELL");
if (field_by_value(&kbmap)->flags & FLG_GET) {
kbmap.maplen = KS_NUMKEYCODES;
if (ioctl(fd, WSKBDIO_GETMAP, &kbmap) < 0)
- err(1, "WSKBDIO_GETMAP");
+ err(EXIT_FAILURE, "WSKBDIO_GETMAP");
}
repeat.which = 0;
@@ -122,7 +128,7 @@
repeat.which |= WSKBD_KEYREPEAT_DODELN;
if (repeat.which != 0 &&
ioctl(fd, WSKBDIO_GETKEYREPEAT, &repeat) < 0)
- err(1, "WSKBDIO_GETKEYREPEAT");
+ err(EXIT_FAILURE, "WSKBDIO_GETKEYREPEAT");
dfrepeat.which = 0;
if (field_by_value(&dfrepeat.del1)->flags & FLG_GET)
@@ -131,15 +137,15 @@
dfrepeat.which |= WSKBD_KEYREPEAT_DODELN;
if (dfrepeat.which != 0 &&
ioctl(fd, WSKBDIO_GETKEYREPEAT, &dfrepeat) < 0)
- err(1, "WSKBDIO_GETKEYREPEAT");
+ err(EXIT_FAILURE, "WSKBDIO_GETKEYREPEAT");
if (field_by_value(&ledstate)->flags & FLG_GET)
if (ioctl(fd, WSKBDIO_GETLEDS, &ledstate) < 0)
- err(1, "WSKBDIO_GETLEDS");
+ err(EXIT_FAILURE, "WSKBDIO_GETLEDS");
if (field_by_value(&kbdencoding)->flags & FLG_GET)
if (ioctl(fd, WSKBDIO_GETENCODING, &kbdencoding) < 0)
- err(1, "WSKBDIO_GETENCODING");
+ err(EXIT_FAILURE, "WSKBDIO_GETENCODING");
if (field_by_value(&keyclick)->flags & FLG_GET) {
ioctl(fd, WSKBDIO_GETKEYCLICK, &keyclick);
@@ -154,7 +160,7 @@
if (scroll.which != 0) {
if (ioctl(fd, WSKBDIO_GETSCROLL, &scroll) == -1) {
if (errno != ENODEV)
- err(1, "WSKBDIO_GETSCROLL");
+ err(EXIT_FAILURE, "WSKBDIO_GETSCROLL");
else
havescroll = 0;
}
@@ -164,6 +170,7 @@
void
keyboard_put_values(int fd)
{
+
bell.which = 0;
if (field_by_value(&bell.pitch)->flags & FLG_SET)
bell.which |= WSKBD_BELL_DOPITCH;
@@ -172,7 +179,7 @@
if (field_by_value(&bell.volume)->flags & FLG_SET)
bell.which |= WSKBD_BELL_DOVOLUME;
if (bell.which != 0 && ioctl(fd, WSKBDIO_SETBELL, &bell) < 0)
Home |
Main Index |
Thread Index |
Old Index