From nobody Tue Feb 10 12:43:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.54 as permitted sender) client-ip=209.85.221.54; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f54.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1625423927; cv=none; d=zohomail.com; s=zohoarc; b=OeVCf8pO9xdOb7Hl940I6pzwBDa9JhD/MNKpLbEoydUFkGDy6YbkQowCXO51UPu6XHmbv9KCewmMTY8rEY3YvsMQSxTefZpgA79RBeJ4JlBcnVSUb57SaNjxEcisTtOUAx5JrO/QGX8uh/yyvMjASYDYunIIlkzgT5mx6EIQhp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625423927; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FN6OTXMHEFJFr00ceuHp4/qEHrZ4IjdpMf6H1iqmh0o=; b=hZCURx3RDyCIOhvf1RsJ7VRMgTDpx3YEO+E4L1E2epu/R4DPtvRI0DjraApfNNXBt28P7UMnKOzjNXVqUAoZP0VNF+FY4k/D6rVmkxKCmHreiS44G5gSN+jUuCR4sRnDx1X+tc458CvmcXdz7w+0W4YgnC9QlfMmFoh6beMDdW4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by mx.zohomail.com with SMTPS id 162542392741690.80693212608048; Sun, 4 Jul 2021 11:38:47 -0700 (PDT) Received: by mail-wr1-f54.google.com with SMTP id f14so18872938wrs.6 for ; Sun, 04 Jul 2021 11:38:46 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id w8sm11268801wrt.83.2021.07.04.11.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jul 2021 11:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FN6OTXMHEFJFr00ceuHp4/qEHrZ4IjdpMf6H1iqmh0o=; b=AUZx9zmfMvkL0j0BW86VqIcCE15/3UymFw4K+GAIe6xaxSbCR4mjYc5mf88A+fH0hp i0r8XhKx4GCs9vlF36WYsPsISY0H3kyk6LFq/Bi3nbD0zsYt7AQnIcFOt6ac6R/7my8a +QCPOwj7CsGqCGWoVpcIFCVfuhYr5uZyhaSRUFV3I+euSL2Z+8slHYs6g8F2RrNtXrj3 E8joCHH7yTTg2xKHYARtSjXDmxX99rcQOUwdI/one4VHlqDpEWJQogGfnm0nWBEtc8tA C3JH/qkHjdPCCA0yDpt1aAQRSrONSWZaPJv44yorXbR7WOPkB8R4213zo32QdUCUzMOp yO5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=FN6OTXMHEFJFr00ceuHp4/qEHrZ4IjdpMf6H1iqmh0o=; b=rXCdAfsDGcHcCK12jh9ez4UZiDyq8QpwNfOhswE5RSzF9HlckhIbmLPvjUHogN69xo T3Qju2JWbszkUZiJ+JWzKvG01jaT8SEWhAoMNTAdtB1vEoJ/b3HCbUucsMbeiYK0tppN uySa0xh/0OC6UyaTEfNQk9er5kSG5zNeVaRt2bDopb/+sSj+6W9jch1Ineaw3nT24EeA DGreQ9aekhUdVyLIhOV8LJi1EXTBB0XxnxA2tiVkh9mU0kDpm3mYrkW1s66K59XoB06j PFr/fAuW2F2agGBjo1tPz1hOu10jkoKaCp4gK1+XmcqON/gvoQ1vsCf6O/hAYjBRxD3k tlDg== X-Gm-Message-State: AOAM5319NUnF01lqbC0G+p8pEVmx/ap7H2qGtG4FsyH2A5rD37OjCqfB xXN3IwcYW8V0p8EVxlyLFMI= X-Google-Smtp-Source: ABdhPJygt6f1ixP0zbFPf4sc7bOmerxQSiVEoOXM5JRMY6l39FF2zSvzUx0IpmoU4ISY7XBCAfXJ8w== X-Received: by 2002:adf:a74a:: with SMTP id e10mr11188230wrd.185.1625423925746; Sun, 04 Jul 2021 11:38:45 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Jiaxun Yang , Laurent Vivier , Aleksandar Rikalo , Taylor Simpson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno , Helge Deller Subject: [PATCH 10/12] linux-user/syscall: Refactor target_to_host_errno_table_init() Date: Sun, 4 Jul 2021 20:37:53 +0200 Message-Id: <20210704183755.655002-11-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210704183755.655002-1-f4bug@amsat.org> References: <20210704183755.655002-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1625423930234100001 To be able to move the errno handling code out of syscall.c, first refactor the target_to_host_errno_table[] initialization as a new init() function. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/syscall.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 64bbf331b28..33b7fef12a8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -509,8 +509,10 @@ static inline int next_free_host_timer(void) =20 #define ERRNO_TABLE_SIZE 1200 =20 -/* target_to_host_errno_table[] is initialized from - * host_to_target_errno_table[] in syscall_init(). */ +/* + * target_to_host_errno_table[] is initialized from + * host_to_target_errno_table[] in target_to_host_errno_table_init(). + */ static uint16_t target_to_host_errno_table[ERRNO_TABLE_SIZE] =3D { }; =20 @@ -637,6 +639,17 @@ static uint16_t host_to_target_errno_table[ERRNO_TABLE= _SIZE] =3D { #endif }; =20 +static void target_to_host_errno_table_init(void) +{ + /* + * Build target_to_host_errno_table[] table + * from host_to_target_errno_table[]. + */ + for (int i =3D 0; i < ERRNO_TABLE_SIZE; i++) { + target_to_host_errno_table[host_to_target_errno_table[i]] =3D i; + } +} + static inline int host_to_target_errno(int err) { if (err >=3D 0 && err < ERRNO_TABLE_SIZE && @@ -7102,7 +7115,6 @@ void syscall_init(void) IOCTLEntry *ie; const argtype *arg_type; int size; - int i; =20 thunk_init(STRUCT_MAX); =20 @@ -7112,11 +7124,7 @@ void syscall_init(void) #undef STRUCT #undef STRUCT_SPECIAL =20 - /* Build target_to_host_errno_table[] table from - * host_to_target_errno_table[]. */ - for (i =3D 0; i < ERRNO_TABLE_SIZE; i++) { - target_to_host_errno_table[host_to_target_errno_table[i]] =3D i; - } + target_to_host_errno_table_init(); =20 /* we patch the ioctl size if necessary. We rely on the fact that no ioctl has all the bits at '1' in the size field */ --=20 2.31.1