Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754897AbcKEQtF (ORCPT ); Sat, 5 Nov 2016 12:49:05 -0400 Received: from mail-yb0-f194.google.com ([209.85.213.194]:34643 "EHLO mail-yb0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753061AbcKEQtD (ORCPT ); Sat, 5 Nov 2016 12:49:03 -0400 MIME-Version: 1.0 In-Reply-To: <20161105163844.GA29546@engestrom.ch> References: <20161105012344.GA28349@engestrom.ch> <20161105013325.3889-1-eric@engestrom.ch> <20161105163844.GA29546@engestrom.ch> From: Rob Clark Date: Sat, 5 Nov 2016 12:49:01 -0400 Message-ID: Subject: Re: [PATCH] drm: move allocation out of drm_get_format_name() To: Eric Engestrom Cc: =?UTF-8?Q?Christian_K=C3=B6nig?= , "dri-devel@lists.freedesktop.org" , Wei Yongjun , Daniel Vetter , Flora Cui , Gustavo Padovan , Tom St Denis , Thomas Hellstrom , Laurent Pinchart , Xinliang Liu , VMware Graphics , Vitaly Prosyak , Alexandre Demers , Intel Graphics Development , Emily Deng , Ken Wang , Junwei Zhang , =?UTF-8?Q?Michel_D=C3=A4nzer?= , Linux Kernel Mailing List , Alex Deucher , Colin Ian King Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id uA5GnBhS025955 Content-Length: 1526 Lines: 39 On Sat, Nov 5, 2016 at 12:38 PM, Eric Engestrom wrote: > On Saturday, 2016-11-05 13:11:36 +0100, Christian König wrote: >> Am 05.11.2016 um 02:33 schrieb Eric Engestrom: >> > +typedef char drm_format_name_buf[32]; >> >> Please don't use a typedef for this, just define the maximum size of >> characters the function might write somewhere. >> >> See the kernel coding style as well: >> > In general, a pointer, or a struct that has elements that can reasonably >> > be directly accessed should **never** be a typedef. >> > > I would normally agree as I tend to hate typedefs ($DAYJOB {ab,mis}uses > them way too much), and your way was what I wrote at first, but Rob Clark's > typedef idea makes it much harder for someone to allocate a buffer of > the wrong size, which IMO is good thing here. IMHO I would make a small test program to verify this actually helps the compiler catch problems. And if it does, I would stick with it. The coding-style should be guidelines, not something that supersedes common sense / practicality. That is my $0.02 anyways.. if others vehemently disagree and want to dogmatically stick to the coding-style guidelines, ok then. OTOH, if this approach doesn't help the compiler catch issues, then it isn't worth it. BR, -R > I can rewrite the typedef out if you think it's better. > > Cheers, > Eric > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel