From: miod Date: Fri, 8 May 2015 19:12:51 +0000 (+0000) Subject: Add a new `don't read back' flag for variables, to prevent reading their value X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=35d84bc06bc0e3642d0d5e2e77e3432af05d62d3;p=openbsd Add a new `don't read back' flag for variables, to prevent reading their value after modifying them. Give this flag to `display.focus', since screen switching is asynchronous, and reading back will return the screen we are switching from if the switch has not completed yet. Also, disallow -= and += syntax for display.focus, as it doesn't make any sense. --- diff --git a/sbin/wsconsctl/display.c b/sbin/wsconsctl/display.c index 87505a82c18..6f789291142 100644 --- a/sbin/wsconsctl/display.c +++ b/sbin/wsconsctl/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.19 2013/10/20 22:07:57 miod Exp $ */ +/* $OpenBSD: display.c,v 1.20 2015/05/08 19:12:51 miod Exp $ */ /* $NetBSD: display.c,v 1.1 1998/12/28 14:01:16 hannken Exp $ */ /*- @@ -56,7 +56,7 @@ struct field display_field_tab[] = { { "depth", &depth, FMT_UINT, FLG_RDONLY }, { "emulations", &emuls, FMT_EMUL, FLG_RDONLY }, { "screentypes", &screens, FMT_SCREEN, FLG_RDONLY }, - { "focus", &focus, FMT_INT, FLG_MODIFY }, + { "focus", &focus, FMT_INT, FLG_NORDBACK }, { "brightness", &brightness, FMT_PC, FLG_MODIFY|FLG_INIT }, { "contrast", &contrast, FMT_PC, FLG_MODIFY|FLG_INIT }, { "backlight", &backlight, FMT_PC, FLG_MODIFY|FLG_INIT }, diff --git a/sbin/wsconsctl/wsconsctl.c b/sbin/wsconsctl/wsconsctl.c index 4d0878bf27f..38b13bdf78e 100644 --- a/sbin/wsconsctl/wsconsctl.c +++ b/sbin/wsconsctl/wsconsctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsconsctl.c,v 1.28 2012/07/14 08:28:47 shadchin Exp $ */ +/* $OpenBSD: wsconsctl.c,v 1.29 2015/05/08 19:12:51 miod Exp $ */ /* $NetBSD: wsconsctl.c,v 1.2 1998/12/29 22:40:20 hannken Exp $ */ /*- @@ -264,8 +264,10 @@ main(int argc, char *argv[]) if (f->flags & FLG_WRONLY) { pr_field(devname, f, setsep); } else { - f->flags |= FLG_GET; - (*sw->getval)(devfd); + if (!(f->flags & FLG_NORDBACK)) { + f->flags |= FLG_GET; + (*sw->getval)(devfd); + } if (f->flags & FLG_DEAD) continue; pr_field(devname, f, setsep); diff --git a/sbin/wsconsctl/wsconsctl.h b/sbin/wsconsctl/wsconsctl.h index 655c8cb794e..7ee37706d95 100644 --- a/sbin/wsconsctl/wsconsctl.h +++ b/sbin/wsconsctl/wsconsctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsconsctl.h,v 1.14 2013/10/20 22:07:57 miod Exp $ */ +/* $OpenBSD: wsconsctl.h,v 1.15 2015/05/08 19:12:51 miod Exp $ */ /* $NetBSD: wsconsctl.h 1.1 1998/12/28 14:01:17 hannken Exp $ */ /*- @@ -53,6 +53,7 @@ struct field { #define FLG_WRONLY 0x0002 /* variable cannot be displayed */ #define FLG_NOAUTO 0x0004 /* skip variable on -a flag */ #define FLG_MODIFY 0x0008 /* variable may be modified with += */ +#define FLG_NORDBACK 0x0010 /* do not read back variable after write */ #define FLG_GET 0x0100 /* read this variable from driver */ #define FLG_SET 0x0200 /* write this variable to driver */ #define FLG_INIT 0x0400 /* init (read) before write */