From 69cc475a72f0fffcdebb9d86bed0df93639175e0 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Tue, 19 Apr 2022 18:41:08 +0900 Subject: [PATCH] rawmidi: fix wrong handling of open flag ALSARawmidi.StreamPair.open() has open_flag parameter for flags parameter of open(2) system call, however internally it's not handled correctly. This commit fixes the bug. Fixes: 909ff54d5265 ("rawmidi: stream_pair: add APIs to open ALSA Rawmidi character device") Signed-off-by: Takashi Sakamoto --- src/rawmidi/stream-pair.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rawmidi/stream-pair.c b/src/rawmidi/stream-pair.c index c2ca684..517d99f 100644 --- a/src/rawmidi/stream-pair.c +++ b/src/rawmidi/stream-pair.c @@ -217,13 +217,14 @@ void alsarawmidi_stream_pair_open(ALSARawmidiStreamPair *self, guint card_id, ALSARAWMIDI_STREAM_PAIR_INFO_FLAG_INPUT)) == 0); g_return_if_fail(error == NULL || *error == NULL); + open_flag &= ~(O_RDWR | O_WRONLY | O_RDONLY); if ((access_modes & ALSARAWMIDI_STREAM_PAIR_INFO_FLAG_OUTPUT) && (access_modes & ALSARAWMIDI_STREAM_PAIR_INFO_FLAG_INPUT)) - open_flag = O_RDWR; + open_flag |= O_RDWR; else if (access_modes & ALSARAWMIDI_STREAM_PAIR_INFO_FLAG_OUTPUT) - open_flag = O_WRONLY; + open_flag |= O_WRONLY; else if (access_modes & ALSARAWMIDI_STREAM_PAIR_INFO_FLAG_INPUT) - open_flag = O_RDONLY; + open_flag |= O_RDONLY; else g_return_if_reached(); -- 2.47.3