Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756746AbcKBSaO (ORCPT ); Wed, 2 Nov 2016 14:30:14 -0400 Received: from conssluserg-03.nifty.com ([210.131.2.82]:62755 "EHLO conssluserg-03.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756196AbcKBSaM (ORCPT ); Wed, 2 Nov 2016 14:30:12 -0400 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com uA2IU4Kn011888 X-Nifty-SrcIP: [209.85.161.180] MIME-Version: 1.0 In-Reply-To: <3e08ed31-b8bf-cba0-67f8-0a66d0cdeeb4@users.sourceforge.net> References: <72e07814-56e9-505a-d660-91ff20b6efea@users.sourceforge.net> <3e08ed31-b8bf-cba0-67f8-0a66d0cdeeb4@users.sourceforge.net> From: Masahiro Yamada Date: Thu, 3 Nov 2016 03:30:03 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: scripts/basic/fixdep: Complete error handling in print_cmdline() To: SF Markus Elfring Cc: Jim Davis , Linux Kbuild mailing list , Michal Marek , LKML , kernel-janitors@vger.kernel.org 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-Length: 722 Lines: 24 2016-11-03 2:38 GMT+09:00 SF Markus Elfring : >>>> + if (printf("cmd_%s := %s\n\n", target, cmdline) < 10) { >>> >>> Rather than scatter fragile magic numbers, like 10, throughout the >>> code, if you're hell-bent on checking for printf errors you could >>> write a little wrapper function that hid the magic number and bundled >>> up the errno stuff. >> >> >> BTW, how the magic number "10" was calculated? > > Does the passed format string indicate how many characters should be > printed at least? So, the check is a bit compromised. The printf() should print at lease 10 characters. If "target" or "cmdline" is not NULL, it should print more. -- Best Regards Masahiro Yamada