Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1510943 > unrolled thread

[PATCH 00/10] scripts/basic: Fine-tuning for seven function implementations

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2016-10-28 10:40 +0200
Last post2016-10-28 10:50 +0200
Articles 4 on this page of 24 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 00/10] scripts/basic: Fine-tuning for seven function  implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-28 10:40 +0200
    [PATCH 08/10] scripts/basic/fixdep: Complete error handling in  print_config() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-28 10:40 +0200
    [PATCH 06/10] scripts/basic/fixdep: Complete error handling in  do_config_file() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-28 10:40 +0200
    [PATCH 05/10] scripts/basic/fixdep: Complete error handling in  parse_dep_file() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-28 10:40 +0200
    [PATCH 07/10] scripts/basic/fixdep: Fix error log output in  do_config_file() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-28 10:40 +0200
    [PATCH 03/10] scripts/basic/fixdep: Use the symbol "MAP_FAILED" in  print_deps() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-28 10:40 +0200
    [PATCH 01/10] scripts/basic/bin2c: Complete error handling in main() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-28 10:40 +0200
      Re: [PATCH 01/10] scripts/basic/bin2c: Complete error handling in main() Jim Davis <jim.epost@gmail.com> - 2016-10-29 00:40 +0200
      Re: [PATCH 01/10] scripts/basic/bin2c: Complete error handling in main() Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-11-02 16:50 +0100
        Re: scripts/basic/bin2c: Complete error handling in main() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-11-02 18:50 +0100
          Re: scripts/basic/bin2c: Complete error handling in main() Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-11-02 19:30 +0100
            Re: scripts/basic/bin2c: Complete error handling in main() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-11-02 19:50 +0100
              Re: scripts/basic/bin2c: Complete error handling in main() Michal Marek <mmarek@suse.com> - 2016-11-03 16:50 +0100
                Re: scripts/basic/bin2c: Complete error handling in main() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-11-03 20:50 +0100
                  Re: scripts/basic/bin2c: Complete error handling in main() Michal Marek <mmarek@suse.com> - 2016-11-04 13:20 +0100
                    Re: scripts/basic/bin2c: Complete error handling in main() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-11-04 14:50 +0100
    [PATCH 09/10] scripts/basic/fixdep: Complete error handling in  print_cmdline() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-28 10:50 +0200
      Re: [PATCH 09/10] scripts/basic/fixdep: Complete error handling in print_cmdline() Jim Davis <jim.epost@gmail.com> - 2016-10-29 01:50 +0200
        Re: scripts/basic/fixdep: Complete error handling in print_cmdline() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-30 16:20 +0100
        Re: [PATCH 09/10] scripts/basic/fixdep: Complete error handling in print_cmdline() Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-11-02 16:40 +0100
          Re: scripts/basic/fixdep: Complete error handling in print_cmdline() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-11-02 18:40 +0100
            Re: scripts/basic/fixdep: Complete error handling in print_cmdline() Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-11-02 19:40 +0100
              Re: scripts/basic/fixdep: Complete error handling in print_cmdline() Michal Marek <mmarek@suse.com> - 2016-11-03 17:00 +0100
    [PATCH 10/10] scripts/basic/fixdep: Combine two fprintf() calls into  one fputs() call in usage() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-28 10:50 +0200

Page 2 of 2 — ← Prev page 1 [2]


#1514042 — Re: scripts/basic/fixdep: Complete error handling in print_cmdline()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-11-02 18:40 +0100
SubjectRe: scripts/basic/fixdep: Complete error handling in print_cmdline()
Message-ID<sz7G1-Pf-3@gated-at.bofh.it>
In reply to#1513919
>>> +       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?

Regards,
Markus

[toc] | [prev] | [next] | [standalone]


#1514062 — Re: scripts/basic/fixdep: Complete error handling in print_cmdline()

FromMasahiro Yamada <yamada.masahiro@socionext.com>
Date2016-11-02 19:40 +0100
SubjectRe: scripts/basic/fixdep: Complete error handling in print_cmdline()
Message-ID<sz8C5-1rE-17@gated-at.bofh.it>
In reply to#1514042
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.




-- 
Best Regards
Masahiro Yamada

[toc] | [prev] | [next] | [standalone]


#1514639 — Re: scripts/basic/fixdep: Complete error handling in print_cmdline()

FromMichal Marek <mmarek@suse.com>
Date2016-11-03 17:00 +0100
SubjectRe: scripts/basic/fixdep: Complete error handling in print_cmdline()
Message-ID<szsAO-5Mg-5@gated-at.bofh.it>
In reply to#1514062
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

[toc] | [prev] | [next] | [standalone]


#1510965 — [PATCH 10/10] scripts/basic/fixdep: Combine two fprintf() calls into one fputs() call in usage()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-10-28 10:50 +0200
Subject[PATCH 10/10] scripts/basic/fixdep: Combine two fprintf() calls into one fputs() call in usage()
Message-ID<sxb1o-5Wd-17@gated-at.bofh.it>
In reply to#1510943
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 28 Oct 2016 09:45:30 +0200

Some data were printed by two separate function calls.
Print the same data by a single call of the function "fputs" instead.

This issue was detected also by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/basic/fixdep.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 911347a..bdd031f 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -122,8 +122,10 @@ char *cmdline;
 
 static void usage(void)
 {
-	fprintf(stderr, "Usage: fixdep [-e] <depfile> <target> <cmdline>\n");
-	fprintf(stderr, " -e  insert extra dependencies given on stdin\n");
+	if (fputs("Usage: fixdep [-e] <depfile> <target> <cmdline>\n"
+		  " -e  insert extra dependencies given on stdin\n", stderr)
+	   < 0)
+		perror("fixdep: usage");
 	exit(1);
 }
 
-- 
2.10.1

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | linux.kernel


csiph-web