[1/3] Report errors when attempting to write keyboard controls

Submitted by Keith Packard on May 31, 2016, 4:29 p.m.

Details

Message ID 1464712190-6397-1-git-send-email-keithp@keithp.com
State Superseded
Headers show
Series "Series without cover letter" ( rev: 1 ) in X.org (DEPRECATED - USE GITLAB)

Not browsing as part of any series.

Commit Message

Keith Packard May 31, 2016, 4:29 p.m.
This is mostly to eliminate a compiler warning.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 src/evdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/evdev.c b/src/evdev.c
index 341db61..4cdfacd 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1122,7 +1122,9 @@  EvdevKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl)
     ev[i].code = SYN_REPORT;
     ev[i].value = 0;
 
-    write(pInfo->fd, ev, sizeof ev);
+    i = write(pInfo->fd, ev, sizeof ev);
+    if (i != sizeof ev)
+	    xf86IDrvMsg(pInfo, X_ERROR, "Failed to set keyboard controls\n");
 }
 
 static int

Comments

On Tue, May 31, 2016 at 09:29:48AM -0700, Keith Packard wrote:
> This is mostly to eliminate a compiler warning.
> 
> Signed-off-by: Keith Packard <keithp@keithp.com>
> ---
>  src/evdev.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/evdev.c b/src/evdev.c
> index 341db61..4cdfacd 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -1122,7 +1122,9 @@ EvdevKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl)
>      ev[i].code = SYN_REPORT;
>      ev[i].value = 0;
>  
> -    write(pInfo->fd, ev, sizeof ev);
> +    i = write(pInfo->fd, ev, sizeof ev);
> +    if (i != sizeof ev)
> +	    xf86IDrvMsg(pInfo, X_ERROR, "Failed to set keyboard controls\n");

please add a new variable 'rc' or 'retval' or whatever here instead of
reusing the index. Plus a strerror would be useful here.

Cheers,
   Peter

>  }
>  
>  static int
> -- 
> 2.8.1