From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 53109158094 for ; Mon, 26 Sep 2022 12:22:55 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 915162BC030; Mon, 26 Sep 2022 12:22:54 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 72DC62BC030 for ; Mon, 26 Sep 2022 12:22:54 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 45E45341269 for ; Mon, 26 Sep 2022 12:22:53 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 828885A2 for ; Mon, 26 Sep 2022 12:22:51 +0000 (UTC) From: "Yixun Lan" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Yixun Lan" Message-ID: <1664194895.8d87286759fdff1a4ed2b9a36f7a1818e031e841.dlan@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-process/psinfo/, sys-process/psinfo/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-process/psinfo/files/psinfo-0.12-char.patch sys-process/psinfo/psinfo-0.12-r1.ebuild X-VCS-Directories: sys-process/psinfo/ sys-process/psinfo/files/ X-VCS-Committer: dlan X-VCS-Committer-Name: Yixun Lan X-VCS-Revision: 8d87286759fdff1a4ed2b9a36f7a1818e031e841 X-VCS-Branch: master Date: Mon, 26 Sep 2022 12:22:51 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: d8f25a05-d4b5-43eb-8458-994fbfad48dd X-Archives-Hash: c00a1033abe303c69a29c2014e4f56ca commit: 8d87286759fdff1a4ed2b9a36f7a1818e031e841 Author: Yixun Lan gentoo org> AuthorDate: Mon Sep 26 12:18:17 2022 +0000 Commit: Yixun Lan gentoo org> CommitDate: Mon Sep 26 12:21:35 2022 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8d872867 sys-process/psinfo: fix 'unsigned char' issue in RISC-V/ARM64 platform Closes: https://bugs.gentoo.org/872821 Signed-off-by: Yixun Lan gentoo.org> sys-process/psinfo/files/psinfo-0.12-char.patch | 65 +++++++++++++++++++++++++ sys-process/psinfo/psinfo-0.12-r1.ebuild | 3 +- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/sys-process/psinfo/files/psinfo-0.12-char.patch b/sys-process/psinfo/files/psinfo-0.12-char.patch new file mode 100644 index 000000000000..d29361633185 --- /dev/null +++ b/sys-process/psinfo/files/psinfo-0.12-char.patch @@ -0,0 +1,65 @@ +Subject: [PATCH] fix 'char' issue in RISC-V (also Arm64) platform + +According to RISC-V psAbi manual[1], "char" is equivalent to "unsigned char", +so in RISC-V/ARM64 the following code will always print out 'false', +while in X86_64 it will print out 'true' + +test() { + char val = EOF; + printf("%s", val == EOF ? "true" : "false"); +} + +According to man page, the following two function return value is 'int': + int getopt(int argc, char *const argv[], + const char *optstring); + int fgetc(FILE *stream); + +so, we use 'int' variable and then convert to 'char' if nencessary + +[1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc +snip of description: + C/C++ type representations + char is unsigned. + +Bug: https://bugs.gentoo.org/872821 + +Signed-off-by: Yixun Lan +--- + psinfo.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/psinfo.c b/psinfo.c +index 90a6d8f..05acedf 100644 +--- a/psinfo.c ++++ b/psinfo.c +@@ -172,14 +172,15 @@ int parse_proc_wchan(FILE * f, struct process_info *p) + int parse_proc_arrayfile(char *name, char ***s) + { + FILE *f; +- int res = 1; ++ int ret, res = 1; + + if ((f = fopen(name, "r")) != NULL) { + char *buf; + int len = 0, bufsize = 1024, count = 0; + + buf = malloc(bufsize); +- while ((buf[len++] = fgetc(f)) != EOF) { ++ while ((ret = fgetc(f)) != EOF) { ++ buf[len++] = ret & 0xFF; + if (buf[len - 1] == 0) { + *s = realloc(*s, (count + 2) * sizeof(char *)); + (*s)[count] = malloc(len); +@@ -673,8 +674,7 @@ void print_help() + int main(int argc, char **argv) + { + struct process_info *p; +- int pid, output_general = 0, output_cpu = 0, output_io = 0, output_memory = 0, output_privilege = 0, output_signal = 0, result = 0; +- char c; ++ int c, pid, output_general = 0, output_cpu = 0, output_io = 0, output_memory = 0, output_privilege = 0, output_signal = 0, result = 0; + + opterr = 0; + if (argc <= 1) { +-- +2.37.3 + diff --git a/sys-process/psinfo/psinfo-0.12-r1.ebuild b/sys-process/psinfo/psinfo-0.12-r1.ebuild index e6faa1baad15..fdf62188a826 100644 --- a/sys-process/psinfo/psinfo-0.12-r1.ebuild +++ b/sys-process/psinfo/psinfo-0.12-r1.ebuild @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 @@ -15,6 +15,7 @@ LICENSE="GPL-2" PATCHES=( "${FILESDIR}/${P}-asneeded.patch" + "${FILESDIR}/${P}-char.patch" ) src_prepare() {