From patchwork Mon May 14 17:46:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 135757 Delivered-To: patches@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2080765lji; Mon, 14 May 2018 10:46:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo51WWcScfWgroiQXWXgITMIZQyCzy/y4oBQY+fcdIjTFnR/at7pzhIGHmrzb+Eadifat0R X-Received: by 2002:adf:9a8e:: with SMTP id a14-v6mr8526330wrc.50.1526319979042; Mon, 14 May 2018 10:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526319979; cv=none; d=google.com; s=arc-20160816; b=UON3mn9oW//kDzVxW0anU5zl8sXKJSRq4Rz8CbFpOn7TuMK3uJHAopkGD5owN3WZNN 2L9H2j1rdBKFQhmMqzL9bmJ2p7K1WzU833dMkxEUAC1Rw/ozj1f4TZksUY1RRYVY/cgX X/yC+wy4H4xNg+Rul/LLFJA8MwwR8h+0cDal3z9PJbz46+BlrYvYW3/E/zdHnlPPhjWS 0WZyn7gJEaekyULh4TFWYe18fiTBpj4xs+rgM/GHoqBzwPzuUy90lKjZkkRwWuoVWtY2 /nAXfY+JwEAU1nQFS0m1Uqg8JCSreSYohtFdRFIdtuyeTN91wZhAKF4mIRgjS2wO8168 cf8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=YqtDbV/XCMPKnJLSXaqo5/i7LT4u3bg0k+3SsI15P/U=; b=h98DLvxVwg4GS0MQSUW7gF0c3aIjnmYUjMUvT4Cn5t1X68GoyvFde1GRxWeuVBeFbU 7Z+EhiTZEOY8urlUBLQfvIN7Vf9SoH8jSMoOHUc9kxVGBf8ruYZXgG73MUVABuYbPXFR XbokeEvV9ZZKQjBtXAMY9ZJQKuqtA0nqIkp4J0gm/O9Lr5L9X7q/+3At1XuNmcFITrxg B6TkcoQY3MSWjoH7vsrzwB9/0Rg9ha5qGXKmpHtwNcuHm3I3xmRb2Gh0//KG7i4Rgpoq JrqPLMlJDtN8tI5wS3ce75aTZIquWI8QmbRpbrpah29bMoGCZJjCdXJgxFVSEEvvHJjY JjgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id u2-v6si8819102wrc.112.2018.05.14.10.46.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 10:46:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1fIHY9-0000K6-Jf; Mon, 14 May 2018 18:46:17 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Laurent Vivier , Riku Voipio Subject: [PATCH] linux-user: Assert on bad type in thunk_type_align() and thunk_type_size() Date: Mon, 14 May 2018 18:46:16 +0100 Message-Id: <20180514174616.19601-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.0 In thunk_type_align() and thunk_type_size() we currently return -1 if the value at the type_ptr isn't one of the TYPE_* values we understand. However, this should never happen, and if it does then the calling code will go confusingly wrong because none of the callsites try to handle an error return. Switch to an assertion instead, so that if this does somehow happen we'll have a nice clear backtrace of what happened rather than a weird crash or misbehaviour. This also silences various Coverity complaints about not handling the negative return value (CID 1005735, 1005736, 1005738, 1390582). Signed-off-by: Peter Maydell --- include/exec/user/thunk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h index f19ef4b230..840d6d899b 100644 --- a/include/exec/user/thunk.h +++ b/include/exec/user/thunk.h @@ -135,7 +135,7 @@ static inline int thunk_type_size(const argtype *type_ptr, int is_host) se = struct_entries + type_ptr[1]; return se->size[is_host]; default: - return -1; + g_assert_not_reached(); } } @@ -173,7 +173,7 @@ static inline int thunk_type_align(const argtype *type_ptr, int is_host) se = struct_entries + type_ptr[1]; return se->align[is_host]; default: - return -1; + g_assert_not_reached(); } }