mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-20 07:40:07 +00:00
keyboard_control GETCH better err handling
GETCH - return always -1 on error, not -1 when read returned 0 and -2 if -1 - the actual value doesn't seem to be checked by any of caller. CID 472180 should be perhaps fixed
This commit is contained in:
@@ -87,6 +87,7 @@
|
||||
#include "module.h"
|
||||
#include "types.h" // for video_desc
|
||||
#include "utils/color_out.h"
|
||||
#include "utils/misc.h" // for ug_strerror
|
||||
#include "utils/thread.h"
|
||||
#include "video.h"
|
||||
|
||||
@@ -310,7 +311,15 @@ GETCH()
|
||||
{
|
||||
unsigned char ch = 0;
|
||||
const ssize_t ret = read(0, &ch, sizeof ch);
|
||||
return ret <= 0 ? (int) ret - 1 : ch;
|
||||
if (ret > 0) {
|
||||
return ch;
|
||||
}
|
||||
if (ret == 0) {
|
||||
MSG(WARNING, "read returned 0!\n");
|
||||
} else {
|
||||
MSG(WARNING, "read error: %s\n", ug_strerror(errno));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
#define GETCH getch
|
||||
|
||||
Reference in New Issue
Block a user