Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3051783imm; Sun, 1 Jul 2018 11:06:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdpaDK2UbiNjkc4EIDKVmcjLTEPv/uKM1AnZSfJB5eg75valOIA3wJdz/kEf6Ig1pzNduWp X-Received: by 2002:a62:8181:: with SMTP id t123-v6mr9730190pfd.141.1530468413892; Sun, 01 Jul 2018 11:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530468413; cv=none; d=google.com; s=arc-20160816; b=Fb9MuuTWsEvuOfCLL3P1yA22PAxIT+yXTi+TcEiUBKT+dU7u/b8tNysoSDKOTZd0Ts aVf9MbW2pgB5mvXfQ3cX/VerwHi0GU6CO5v/iYPqC5AVI8E8ZSvo7bSFbiCtoA57XFmU rBafLgevqE8Fn1pBUKebNO0j1eLi6HVVjPE4Lpt1qDFsJaLJy7Ww2UDj8EfXtxoLdlvs S0JlbLp+FR4IcwKPGyXkCAF/vD//XAzvMAOwpuf0Eb1hyw3uOWZuITsGrvlG/FnAjed8 lF65BG/+uMfjZdBxh/II1YIwngNRUkx3D4G+cIfGh2rSFuXX952kKlFYREgC2KVgQaun fInQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1wOUb+jdLPKJmGkTm6HUo+vVLIcVYytggUd/On2Q7hs=; b=Dq8UYv7ogyio4cDb+9Xui1l/EwoNtSxdee5UhoWz4ec/EuZcfhdqN1Z8kEU6N4iNZA 7SS5b6RZXTGrZk3xiKrf4lUeQ5HVPVrcXsT2mOumRR7R7PeaIlOgLZERgyo9zenY6E0s pAoQSOS0luEvOE+e0B5E4gGz2zRhyqXOgkf2uzhQrFB02AD6nHQEna2cntMdi7UVljMz gs+9bbTCeQJubTOvt1FkAxIgUEec7UuLfcV3/4hXdCP8rBH2rWZvSK2MouKjlt/QsL1f 1KoYk4PhVou7dh2JzK10bps0GkbTqNlTtM1vlnnhhj/SLsnCpVPgXEd2Y8GnRpWslZDh /7kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n59-v6si14153652plb.198.2018.07.01.11.06.39; Sun, 01 Jul 2018 11:06:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753822AbeGASFY (ORCPT + 99 others); Sun, 1 Jul 2018 14:05:24 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:53482 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965704AbeGASEt (ORCPT ); Sun, 1 Jul 2018 14:04:49 -0400 X-IronPort-AV: E=Sophos;i="5.51,295,1526335200"; d="scan'208";a="271074622" Received: from palace.rsr.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/AES128-SHA256; 01 Jul 2018 20:04:44 +0200 From: Julia Lawall To: linux-usb@vger.kernel.org, joe@perches.com, Chengguang Xu Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 0/3] cast sizeof to int for comparison Date: Sun, 1 Jul 2018 19:32:02 +0200 Message-Id: <1530466325-1678-1-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Comparing an int to a size, which is unsigned, causes the int to become unsigned, giving the wrong result. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @safe disable not_int2@ int x; position p; binary operator op = {<,<=}; expression e; @@ ( x < 0 || (x@p op e) | x <= 0 || (x@p op e) | x > 0 && (x@p op e) | x >= 0 && (x@p op e) ) @@ int x; type t; expression e,e1; identifier f != {strlen,resource_size}; position p != safe.p; binary operator op = {<,<=}; @@ *x = f(...); ... when != x = e1 when != if (x < 0 || ...) { ... return ...; } ( *x@p op sizeof(e) | *x@p op sizeof(t) ) // --- drivers/input/mouse/elan_i2c_smbus.c | 2 +- drivers/media/usb/gspca/kinect.c | 2 +- drivers/usb/wusbcore/security.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)