From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932733AbbIUNsx (ORCPT ); Mon, 21 Sep 2015 09:48:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34638 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932348AbbIUNsu (ORCPT ); Mon, 21 Sep 2015 09:48:50 -0400 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <1442842450-29769-33-git-send-email-a.hajda@samsung.com> References: <1442842450-29769-33-git-send-email-a.hajda@samsung.com> <1442842450-29769-1-git-send-email-a.hajda@samsung.com> To: Andrzej Hajda Cc: dhowells@redhat.com, linux-kernel@vger.kernel.org, Bartlomiej Zolnierkiewicz , Marek Szyprowski , linux-cachefs@redhat.com Subject: Re: [PATCH 32/38] fs/cachefiles: remove invalid checks MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17907.1442843326.1@warthog.procyon.org.uk> Date: Mon, 21 Sep 2015 14:48:46 +0100 Message-ID: <17908.1442843326@warthog.procyon.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andrzej Hajda wrote: > The problem has been detected using proposed semantic patch > scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1]. This is a problem in your test. There's no actual problem with the code. > - ASSERT(cache->fstop_percent >= 0 && This is fine. The compiler should just ignore it. > - cache->fstop_percent < cache->fcull_percent && > - cache->fcull_percent < cache->frun_percent && > - cache->frun_percent < 100); > + ASSERT(cache->fstop_percent < cache->fcull_percent && > + cache->fcull_percent < cache->frun_percent); You've lost the upper bound check. > - if (datalen < 0 || datalen > PAGE_SIZE - 1) > - if (fstop < 0 || fstop >= cache->fcull_percent) > - if (bstop < 0 || bstop >= cache->bcull_percent) These are all fine. The compiler should just ignore them. David