linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Marek <mmarek@suse.com>
To: Masahiro Yamada <yamada.masahiro@socionext.com>,
	SF Markus Elfring <elfring@users.sourceforge.net>
Cc: Jim Davis <jim.epost@gmail.com>,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: scripts/basic/fixdep: Complete error handling in print_cmdline()
Date: Thu, 3 Nov 2016 16:57:44 +0100	[thread overview]
Message-ID: <9d92d3ad-d57d-d131-ebd7-2f38a423da7c@suse.com> (raw)
In-Reply-To: <CAK7LNARfBrH2ve9J8D=iq1mdk1j-G_kOXT7CL017uqBOYPRL=Q@mail.gmail.com>

Dne 2.11.2016 v 19:30 Masahiro Yamada napsal(a):
> 2016-11-03 2:38 GMT+09:00 SF Markus Elfring <elfring@users.sourceforge.net>:
>>>>> +       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.

printf() / fprintf() return a negative value if an error such as ENOSPC
occurs. So just check for < 0 and preferably use a wrapper.

Michal

  reply	other threads:[~2016-11-03 15:57 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-28  8:30 [PATCH 00/10] scripts/basic: Fine-tuning for seven function implementations SF Markus Elfring
2016-10-28  8:31 ` [PATCH 01/10] scripts/basic/bin2c: Complete error handling in main() SF Markus Elfring
2016-10-28 22:32   ` Jim Davis
2016-11-02 15:41   ` Masahiro Yamada
2016-11-02 17:48     ` SF Markus Elfring
2016-11-02 18:26       ` Masahiro Yamada
2016-11-02 18:46         ` SF Markus Elfring
2016-11-03 15:42           ` Michal Marek
2016-11-03 19:48             ` SF Markus Elfring
2016-11-04 12:19               ` Michal Marek
2016-11-04 12:48                 ` SF Markus Elfring
2016-10-28  8:32 ` [PATCH 02/10] scripts/basic/fixdep: Complete error handling in print_deps() SF Markus Elfring
2016-10-28  8:33 ` [PATCH 03/10] scripts/basic/fixdep: Use the symbol "MAP_FAILED" " SF Markus Elfring
2016-10-28  8:34 ` [PATCH 04/10] scripts/basic/fixdep: Fix error log output " SF Markus Elfring
2016-10-28  8:35 ` [PATCH 05/10] scripts/basic/fixdep: Complete error handling in parse_dep_file() SF Markus Elfring
2016-10-28  8:36 ` [PATCH 06/10] scripts/basic/fixdep: Complete error handling in do_config_file() SF Markus Elfring
2016-10-28  8:37 ` [PATCH 07/10] scripts/basic/fixdep: Fix error log output " SF Markus Elfring
2016-10-28  8:39 ` [PATCH 08/10] scripts/basic/fixdep: Complete error handling in print_config() SF Markus Elfring
2016-10-28  8:40 ` [PATCH 09/10] scripts/basic/fixdep: Complete error handling in print_cmdline() SF Markus Elfring
2016-10-28 23:42   ` Jim Davis
2016-10-30 15:17     ` SF Markus Elfring
2016-11-02 15:35     ` [PATCH 09/10] " Masahiro Yamada
2016-11-02 17:38       ` SF Markus Elfring
2016-11-02 18:30         ` Masahiro Yamada
2016-11-03 15:57           ` Michal Marek [this message]
2016-10-28  8:41 ` [PATCH 10/10] scripts/basic/fixdep: Combine two fprintf() calls into one fputs() call in usage() SF Markus Elfring
2017-11-10 18:32 ` [PATCH 00/10] scripts/basic: Fine-tuning for seven function implementations SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d92d3ad-d57d-d131-ebd7-2f38a423da7c@suse.com \
    --to=mmarek@suse.com \
    --cc=elfring@users.sourceforge.net \
    --cc=jim.epost@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).