From patchwork Sun May 19 20:37:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164538 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4804169ili; Sun, 19 May 2019 14:16:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMxlGwHjKMCGRo6/ug1g0roOQ1dHigEuJFHbr9G/R4u39yP6nnPPe6f+qb+6m6YWShAwzi X-Received: by 2002:a17:906:b741:: with SMTP id fx1mr3206408ejb.45.1558300564997; Sun, 19 May 2019 14:16:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300564; cv=none; d=google.com; s=arc-20160816; b=YjFG7QNKt5Am0Alzfc57tSRjurFsbRDX4sRtAWNtL4xJ8QsHvyZwCLp8Gd7X6hzCQO 3A9X6FjRvniY3LAIp7owGRuzldhfMq2oZNs83bMTqJVLUM1ewjY8tJJcBdLwG2goG6RD uh8hX8yqupWirB67Tc3W1GBPYQ6AIjRU7a2WpgZpiV7nWcBzoOd5NcQRmBbzTJClNAO8 oMZdvU8901BhKiIAnAOOiwcWvWVBZHkD4APhXQ+UYVYtUpx7AeiZy8XmPOL9+ptZIw0W KXEuGRHBE1Td9+hLrFluQ6fYZ8rb8NM6gziXJogne9IV8O3y8Tb1Ng6r+gxFpPriAoYD JQUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=gMLsvL1jnb8FN6BVtc8z8p85LWUNX5tvXcqS5qNVubg=; b=nf0HhpUMyDVsEeYQVj2D4QR4d/UthjRGVizpWuK6rjeM/M8rqBDszZU8dodEDKjU3s 6Uxfm4Rw203/eD1bqkZBpPeoKmJKX+iquXt1sLlfDPq23/BgvIAEeanMZ9xNvrt01mtx UgJ8D7rwmgrmDXFOUXoC+0KDvxP3HoZaL8bpTa2t6Nhyn44fEjWdTvcEASWPKsNq/abA PgLVnG4rWMHSuHlO3TBVvl56dBLK0/Oo1dWLbJhDcBFaH27kkXXHZT4CZUJwtZVbbYgF NpbNSOyMLbU98q2RDSCKuml3u7v6mS5Q2jGqDjPMicd6uKUFtQKWVWBIqEsgezKwtTqz Hayg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="H/24O4J2"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w13si1777423ejj.196.2019.05.19.14.16.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:16:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="H/24O4J2"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTA3-0002l5-Tv for patch@linaro.org; Sun, 19 May 2019 17:16:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZl-0003ky-43 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZk-0004aU-7h for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:33 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:34655) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZk-0004Ze-23 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:32 -0400 Received: by mail-pg1-x542.google.com with SMTP id c13so5748150pgt.1 for ; Sun, 19 May 2019 13:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gMLsvL1jnb8FN6BVtc8z8p85LWUNX5tvXcqS5qNVubg=; b=H/24O4J2CtVeAW2bEmUi0Fq2daN8ycHshgm6J7xFzJ7+9qMyu9O9tLWXf3NtBSU9yd NsY59B95gfilKGxFAFHZliRhsqeBgw2nEGcatkoqFdD/DTfXeodTIAZIqJgqO2pMY5cB XEnqsbq1Q5zgWvyGN/sy/MKFc0OlfX9RzGDBH4Y41oPOXORWb0/efAvqoZqbBzGXGY4q i5MhimEObeT8gBBvfH16W7cbJJUmkvrYEueemJdx95zuWXTyPfZzhTB5I9r+CUpOAGzN v8zPUNAxDG1/jKY0tTeusQXXa4Z55b4M6pFABIyrIJAeEjUOIOI67dvzuhnfS29+j6Ta D6Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gMLsvL1jnb8FN6BVtc8z8p85LWUNX5tvXcqS5qNVubg=; b=bJLbH4K5mEAo+KEp7hiwjai00NY7Df9gQNt0Ci4eXuQKs15yZFXXuEzWza2LFY5zc+ q0u4/KYMlZPd4O8yZDfDHFKAcR9O3wmHES7mRPB5kYNCE7nwtwegROVX36AnKbn6GiSf MrmkV5gluHTLd3YX2cGjqSqgQuQKULOUIhY7M2FjwBB1OgqvhsSApbhsmkq85G1lQneI ILGi07VpJV8sZWaINEboWXogU7ZywIlDIWMtWDvZWOmQB/s2DX2wiRSLE8mNlNZ5J1d6 LNJYOp5HLaAGW/Nq5bOKVVVM6m/WmguH/p93JhzTSAFnszYGfAUYzNuB3zzBtLznq7aA szrA== X-Gm-Message-State: APjAAAVKSApRYxdc46gEW4/dzL4eeSoXr7FvgARlhEUUuppwvfvUQyjj INR2itbXC10Pd240TU53pajAzY0hkgo= X-Received: by 2002:a63:d045:: with SMTP id s5mr8723728pgi.199.1558298310842; Sun, 19 May 2019 13:38:30 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:01 -0700 Message-Id: <20190519203726.20729-50-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v7 49/74] linux-user: Remove sentinel from ioctl_entries X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Iterate based on the size of the array instead. Signed-off-by: Richard Henderson --- linux-user/syscall-ioctl.inc.c | 14 +++++++------- linux-user/syscall.c | 6 ++---- 2 files changed, 9 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-ioctl.inc.c b/linux-user/syscall-ioctl.inc.c index 15d87b9663..fc7df62017 100644 --- a/linux-user/syscall-ioctl.inc.c +++ b/linux-user/syscall-ioctl.inc.c @@ -773,7 +773,6 @@ static IOCTLEntry ioctl_entries[] = { #define IOCTL_IGNORE(cmd) \ { TARGET_ ## cmd, 0, #cmd }, #include "ioctls.h" - { 0, 0, }, }; /* ??? Implement proper locking for ioctls. */ @@ -789,16 +788,17 @@ SYSCALL_IMPL(ioctl) int target_size; void *argptr; - for (ie = ioctl_entries; ; ie++) { - if (ie->target_cmd == 0) { - gemu_log("Unsupported ioctl: cmd=0x%04x\n", cmd); - return -TARGET_ENOSYS; - } + for (ie = ioctl_entries; + ie < ioctl_entries + ARRAY_SIZE(ioctl_entries); + ie++) { if (ie->target_cmd == cmd) { - break; + goto found; } } + gemu_log("Unsupported ioctl: cmd=0x%04x\n", cmd); + return -TARGET_ENOSYS; + found: arg_type = ie->arg_type; if (ie->do_ioctl) { return ie->do_ioctl(ie, buf_temp, fd, cmd, arg); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8f90affe2f..5871d3e711 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8173,7 +8173,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, void syscall_init(void) { - IOCTLEntry *ie; const argtype *arg_type; int size; int i; @@ -8203,8 +8202,8 @@ void syscall_init(void) * 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. */ - ie = ioctl_entries; - while (ie->target_cmd != 0) { + for (i = 0; i < ARRAY_SIZE(ioctl_entries); i++) { + IOCTLEntry *ie = &ioctl_entries[i]; if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) == TARGET_IOC_SIZEMASK) { arg_type = ie->arg_type; @@ -8228,6 +8227,5 @@ void syscall_init(void) ie->name, ie->target_cmd, ie->host_cmd); } #endif - ie++; } }