Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758239AbeAHX32 (ORCPT + 1 other); Mon, 8 Jan 2018 18:29:28 -0500 Received: from mail-it0-f44.google.com ([209.85.214.44]:37646 "EHLO mail-it0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758187AbeAHX3Y (ORCPT ); Mon, 8 Jan 2018 18:29:24 -0500 X-Google-Smtp-Source: ACJfBovgKpuFgMAo1K3loMQrFBWfO9IFRAAsDLXLBJBBoHXxjUDUONhqduFNydfFSJvX0I7NXKW7F10/RxdAlWHGFi4= MIME-Version: 1.0 In-Reply-To: <20171228150019.27953-1-ynorov@caviumnetworks.com> References: <20171228150019.27953-1-ynorov@caviumnetworks.com> From: Rasmus Villemoes Date: Tue, 9 Jan 2018 00:29:23 +0100 Message-ID: Subject: Re: [PATCH 1/2] bitmap: new bitmap_copy_safe and bitmap_{from,to}_arr32 To: Yury Norov Cc: linux-kernel@vger.kernel.org, Andrew Morton , Ben Hutchings , David Decotigny , "David S . Miller" , Geert Uytterhoeven , Matthew Wilcox Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 28 December 2017 at 16:00, Yury Norov wrote: > > In this patch, bitmap_copy_safe and bitmap_{from,to}_arr32 are introduced. > > 'Safe' in bitmap_copy_safe() stands for clearing unused bits in bitmap > beyond last bit till the end of last word. It is useful for hardening > API when bitmap is assumed to be exposed to userspace. I agree completely with getting rid of the complexity of the u32array functions, and also think they should simply be implemented as a memcpy() when possible. I'm not a fan of the _safe suffix, though. It doesn't say what it's safe from. For example, one possible interpretation is that it allows src or dst to be NULL (becoming a noop in such a case). Why not say what it does? _clear_tail, _clear_rest, something like that. Or maybe, can we simply make bitmap_copy behave that way? Hm, probably not, a bit too many users to check they'd all be ok with that. Rasmus