Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1428399imm; Sun, 15 Jul 2018 07:31:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdjsD+USrPTPkWGZO5XaTUDkop12yPIBeq3CN/IVwg3X2fdQUL01jLbOj8gA+ywvFo6qSk8 X-Received: by 2002:a17:902:201:: with SMTP id 1-v6mr13483982plc.310.1531665117232; Sun, 15 Jul 2018 07:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531665117; cv=none; d=google.com; s=arc-20160816; b=KIQXSjLnZQ/Cfw23lI+qTS7kBYEEDlutH7lbqyzWBR2Z6pnShzbFcte6JJKy/Nm7iq +iFnJhGtLSBn9euFsszDzJdbWn1/L4sd+l5ylKlfgt15lg2kslejakg3+tQsbObyAaQh ycpflEVg9e96Fbxf74xiH02qP8Xva3DdcCTykKSUv6q7++XFq1ZYTgmb6gATmSO8AlP0 jHqp7tBs7M3fUlwA7vdRP94LIQuwcMSGZsS9SF4OpxMsqaMiiNGOhsfRLeMIljDsDjYR ANkl8ZGl4YKbYt9z5TufOcO3hFkBeF5kId7ZZ41UVw59h/Xqj5JEFoQYnBLNjkq3Cmyu Rbtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=XiOEHf2m0WHz2jnZ6mzGPzUdslGpzAlP1FdZjLXma5c=; b=STpbL+BlGQLwjjQoIss56EpM00tB50m82fQV7NdEVC0x70QgCmQ5mZRd47ZeA69ujW qIkDGYFpwGIZ1bJ8i8lvKn5sYDNi6GK5ljaG0paHrnshgsQ5KQueZqSRBLMiTn0E9Z08 viwqb0ocveU05rhLY8VlhBkuGid9pjBE3Hncm+98Yt+E859kUUsMxcCTXAR5KHXXkHVE 6Sik1uzZQsNDGlpQE4+/ByX9cM4k8kq4tifd1mlaGAm1L5plamieXXNsujvNKYIoW/C3 ODYfXUZlLrZOsU0HtZV9mofiLV3Q+YGhD+v0Hf3dgIzCCoYe0R5B+GDGVMNI4ZTEjdf2 BZZw== 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 x1-v6si15941254pln.129.2018.07.15.07.31.42; Sun, 15 Jul 2018 07:31:57 -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 S1726900AbeGOOx6 (ORCPT + 99 others); Sun, 15 Jul 2018 10:53:58 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:50410 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726274AbeGOOx6 (ORCPT ); Sun, 15 Jul 2018 10:53:58 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fei2t-0003Bw-M7; Sun, 15 Jul 2018 14:30:43 +0000 Date: Sun, 15 Jul 2018 15:30:43 +0100 From: Al Viro To: OGAWA Hirofumi Cc: Andrew Morton , Anatoly Trosinenko , linux-kernel@vger.kernel.org Subject: Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1 Message-ID: <20180715143043.GM30522@ZenIV.linux.org.uk> References: <878t6c7f8p.fsf@mail.parknet.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878t6c7f8p.fsf@mail.parknet.co.jp> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 15, 2018 at 11:20:06PM +0900, OGAWA Hirofumi wrote: > +static inline bool fat_valid_entry(struct msdos_sb_info *sbi, int entry) > +{ > + if (entry < FAT_START_ENT || sbi->max_cluster <= entry) > + return false; > + return true; > +} Pet peeve: if (...) return false; return true; instead of return !....; In this case, return entry >= FAT_START_ENT && entry < sb->max_cluster;