Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751699AbcKFJrn (ORCPT ); Sun, 6 Nov 2016 04:47:43 -0500 Received: from mail-by2nam03on0061.outbound.protection.outlook.com ([104.47.42.61]:47328 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751530AbcKFJrk (ORCPT ); Sun, 6 Nov 2016 04:47:40 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Christian.Koenig@amd.com; Subject: Re: [PATCH] drm: move allocation out of drm_get_format_name() To: Rob Clark , Eric Engestrom References: <20161105012344.GA28349@engestrom.ch> <20161105013325.3889-1-eric@engestrom.ch> <20161105163844.GA29546@engestrom.ch> CC: "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 From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <8af873a2-31a9-1146-289d-35d2e48edffa@amd.com> Date: Sun, 6 Nov 2016 10:47:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [2a02:908:1251:7981:6cae:707c:33c5:6b08] X-ClientProxiedBy: AMSPR04CA0062.eurprd04.prod.outlook.com (10.242.87.180) To BN6PR12MB1298.namprd12.prod.outlook.com (10.168.227.148) X-MS-Office365-Filtering-Correlation-Id: eb41f2d9-78ee-4af1-9ae3-08d40629f1e2 X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1298;2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lY9O6orhguIeluB4V1u5WJdioV18AzCQzifOZ+oCZqdaiYQwlF/Xp/Mz X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(131327999870524)(217544274631240); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026);SRVR:BN6PR12MB1298;BCL:0;PCL:0;RULEID:;SRVR:BN6PR12MB1298; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1298;4:L1XIQgTGyUyi5HnpaDryMVyK8LASa+Me8JbpGKRF6cxu7whMHkSo2xwvUlnXYqAVv8smpHAD0IvA19VT3FK+FhXawKlL8QG9xkF81KzxFS7f19B64FHFFEzZj9iaDtJVuPZAz5GKFoHfMcKgHV5AzkXxjDuMOZQ9YO1crpOyN1lAq84PGviFnr0ZZtVi2QfXl0jXzX7ZMURJNSJWmdhRK4cf0CWon1VLvGrJYBH1uflvUX9ErkNm5Y3gXy0nGE/lkk8b7UAR/fsLVBcfuDP0kAFeYF0uvm27vREXCqHMwD4jmgZRxeQlXYBoca2T+hGL5YXJorTbl3wQ3KDmgohd+qzkatfDZUQMnS06c0w0xjo0mrEjgn82KF9UM13/00ueA84QyveuorksHAuMdXUGcYQkqlpgDoV0WGLR8NEO1XsnZxc027vbu5bBOZ+mt5qUkA711AQn2bAgn+6uXJWte97C3HD8b9yxERie9L+SGduru+XLaSqhl5+p+dEGQlbg X-Forefront-PRVS: 0118CD8765 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(377424004)(199003)(24454002)(377454003)(23676002)(50466002)(586003)(189998001)(8676002)(81156014)(65956001)(81166006)(15975445007)(65806001)(77096005)(47776003)(7416002)(7736002)(33646002)(4001350100001)(7846002)(2950100002)(6666003)(5001770100001)(97736004)(65826007)(36756003)(93886004)(5660300001)(2870700001)(64126003)(31686004)(42186005)(2906002)(83506001)(19580405001)(19580395003)(305945005)(68736007)(101416001)(4326007)(105586002)(31696002)(86362001)(76176999)(54356999)(92566002)(106356001)(50986999)(1706002)(6116002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1298;H:[IPv6:2a02:908:1251:7981:6cae:707c:33c5:6b08];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxMjk4OzIzOjBPbjlodWFKWnJIVnM3aDJHZzNXZ1VkaU1T?= =?utf-8?B?YU1Jb1ZXYXZWakpQOWVIVWV1YTRSTkhCU1BVYWpPZm40cEFhN3BtblZERjV1?= =?utf-8?B?alN1cFBGWnY4Q0RmeGFrSE5ZS28wSVNGMXVsVEF6S2tpTWJmdlA4TXcvNzJW?= =?utf-8?B?MjVkZEhlVFZLWGRkb0hmQS93elFwWFdOU3VSMnBFbXo1bnRLUmhObnJ6Q3JX?= =?utf-8?B?OUd6bjZRenc5MmczcDVLckFzV2pHRS9jNkxQNzg5b21uOGVSdldqTHFUT09S?= =?utf-8?B?UTIzOFNPOHFuVzB1U3E4NVBmM0R2ak5PaHJQbGx5RlZuRE9Dd3owMElKbGhZ?= =?utf-8?B?VjZ2L29FNUdxUHJBbFJMd2hlY1hHSlF0YUxNQjlNdHdCbVVnR0JRTkpXdXdK?= =?utf-8?B?c2ZRL2pFVVBhNWR3SDVWTi9Uc1BTd2NoekxmcEZWODMyd1QwTGJCZzZONjNQ?= =?utf-8?B?Snkzai9qY1I2UUJRVGd2Y2QwWFVEYktGcFRmQ0tTV1NiekE0ZjNQSnZhOUNC?= =?utf-8?B?VzYrSVVKL09kbFkzNEpsdFdNV1lJTms3Ujd4WmN6eDVGQTJtQzdFSHpBWEVP?= =?utf-8?B?Q3REb1hMZ2NhSkVxd0JQcUVZNnE4eGlzMUVGd1E1ejBySitpSTFWUzE4WWc2?= =?utf-8?B?VHRJS2R2WnZMOGwvSEQydUFJTjI0Y0wxRW1VMzRXd2JwNWVRM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diagnostics: 1;BN6PR12MB1298;7:GFbmLMKr8tiyE2+MJZeo+OqUDESXojUBRacuU7/EGji1Eavb6fokBSeszWYZwsWrZjjm/QOc5thjLBaCTfZVJ5ABIGD4ShL72HV7oeRxia4UIolC51S37zOd2ZlvSe+u9ILQ1b2AOudHy2mreSvuexz8J2aBLmGda4iisvCktQqZGwtMMEXSh6Y3qDsH5uMoXFuBIkJJV5fACdOMMs3toyon3kerOCnowTbx6+o6d7QQINX6gjVEUDDeXy2h7C2ECLRwoByFhANQGOOtzjvcTqBDYDq21EaSyjSpGyfJnUbqVhHnS+H3LRRNILBUfzXavToAfq+/qUQb/V0qzCoWXLxDoSpviF+yYdhB1szBCbM=;20:RnnysybpU0dxa5RcD7jsWyYCVq5559R/H3M5w49r0fP2o0KBNyGrSyosNdWrc7ro0jTM93QKFIKtaQlHs+YOimPb7snPDGjM26O/gEmmgkj4BYJoprASld0VSVBi/xOvJG3oZsaisyiSiVGhr5IwSPgQhqC7JiDR7bt4mzqd0RmBfFSS0UjUKd5/S/q9/+efd3kxRAc2e6kjaQXg3RZs1aa++dHy7uKhlUX+jHC9HvJVkzzA39gsQWvT4Dxbwcx3 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2016 09:47:35.7482 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1298 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2231 Lines: 57 Am 05.11.2016 um 17:49 schrieb Rob Clark: > 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. Well completely agree that we should be able to question the coding style rules, but when we do it we discuss this on a the mailing list first and then start to use it in code. Not the other way around. > > 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. Yeah, exactly that's the point. If I'm not completely mistaken the compiler won't issue a warning here if you pass an array with the wrong size. I think you need something like "struct drm_format_name_buf { char str[32]; };" to trigger this. Apart from that is this function really called so often that using kasprintf() is a problem here? Or is there another motivation behind the change? Regards, Christian. > > 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