!9 [sync] PR-8: fix error handling for sched_setscheduler call

From: @openeuler-sync-bot 
Reviewed-by: @small_leek 
Signed-off-by: @small_leek
This commit is contained in:
openeuler-ci-bot 2023-09-22 02:08:30 +00:00 committed by Gitee
commit f3fb3bd47e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,39 @@
From d2bf87608a1c3f2d62ceb9300a74e9006394c678 Mon Sep 17 00:00:00 2001
From: herengui <herengui@kylinsec.com.cn>
Date: Wed, 31 May 2023 15:01:33 +0800
Subject: [PATCH] alsactl: fix error handling for sched_setscheduler() call
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
As man page says: "If successful, the sched_setparam() function shall return zero."
Without update I got this output in the syslog (journalctl):
abr 16 09:25:30 mypc alsactl[1652]: alsactl 1.2.2 daemon started
abr 16 09:25:30 mypc alsactl[1652]: /usr/bin/alsactl: do_nice:165sched_setparam failed: No such file or directory
If sched_setscheduler() returns 0, so it means that the call was successful.
Signed-off-by: Oscar Megía <megia.oscar@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
alsactl/alsactl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c
index dfb1db7..60d3945 100644
--- a/alsactl/alsactl.c
+++ b/alsactl/alsactl.c
@@ -161,7 +161,7 @@ static void do_nice(int use_nice, int sched_idle)
if (sched_idle) {
if (sched_getparam(0, &sched_param) >= 0) {
sched_param.sched_priority = 0;
- if (!sched_setscheduler(0, SCHED_IDLE, &sched_param))
+ if (sched_setscheduler(0, SCHED_IDLE, &sched_param) < 0)
error("sched_setparam failed: %s", strerror(errno));
} else {
error("sched_getparam failed: %s", strerror(errno));
--
2.40.1

View File

@ -1,6 +1,6 @@
Name: alsa-utils Name: alsa-utils
Version: 1.2.2 Version: 1.2.2
Release: 2 Release: 3
Summary: Advanced linux sound architecture (ALSA) utility to the Linux operating system. Summary: Advanced linux sound architecture (ALSA) utility to the Linux operating system.
License: GPLv2+ License: GPLv2+
URL: http://www.alsa-project.org/ URL: http://www.alsa-project.org/
@ -18,6 +18,7 @@ Provides: alsa-ucm-utils = %{version}-%{release}
Obsoletes: alsa-ucm-utils < %{version}-%{release} Obsoletes: alsa-ucm-utils < %{version}-%{release}
Provides: alsa-topology-utils = %{version}-%{release} Provides: alsa-topology-utils = %{version}-%{release}
Obsoletes: alsa-topology-utils < %{version}-%{release} Obsoletes: alsa-topology-utils < %{version}-%{release}
Patch0001: 0001-alsactl-fix-error-handling-for-sched_setscheduler-ca.patch
%description %description
This package provides command line utilities for audio and MIDI functionality This package provides command line utilities for audio and MIDI functionality
@ -116,6 +117,9 @@ fi
%doc README.md TODO %doc README.md TODO
%changelog %changelog
* Mon Aug 7 2023 panchenbo <panchenbo@kylinsec.com.cn> - 1.2.2-3
- fix error handling for sched_setscheduler call
* Tue Apr 28 2020 Guoshuai Sun <sunguoshuai@huawei.com> - 1.2.2-2 * Tue Apr 28 2020 Guoshuai Sun <sunguoshuai@huawei.com> - 1.2.2-2
- Update to version 1.2.2 - Update to version 1.2.2