Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1551729 > unrolled thread
| Started by | Ingo Molnar <mingo@kernel.org> |
|---|---|
| First post | 2017-01-05 09:10 +0100 |
| Last post | 2017-01-07 10:40 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH RFC] x86, boot: add missing declaration of string functions Ingo Molnar <mingo@kernel.org> - 2017-01-05 09:10 +0100
Re: [PATCH RFC] x86, boot: add missing declaration of string functions Nicholas Mc Guire <der.herr@hofr.at> - 2017-01-07 10:40 +0100
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2017-01-05 09:10 +0100 |
| Subject | Re: [PATCH RFC] x86, boot: add missing declaration of string functions |
| Message-ID | <sWbhw-76-11@gated-at.bofh.it> |
* Nicholas Mc Guire <hofrat@osadl.org> wrote:
> Add the missing declarations of basic string functions to string.h to allow
> a clean build.
>
> Fixes: commit 5be865661516 ("String-handling functions for the new x86 setup code.")
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> ---
>
> sparse issues a set of warnings about missing declarations:
> arch/x86/purgatory/../boot/string.c:18:5: warning: symbol 'memcmp' was not declared. Should it be static?
> arch/x86/purgatory/../boot/string.c:26:5: warning: symbol 'strcmp' was not declared. Should it be static?
> arch/x86/purgatory/../boot/string.c:42:5: warning: symbol 'strncmp' was not declared. Should it be static?
> arch/x86/purgatory/../boot/string.c:58:8: warning: symbol 'strnlen' was not declared. Should it be static?
> arch/x86/purgatory/../boot/string.c:69:14: warning: symbol 'atou' was not declared. Should it be static?
> arch/x86/purgatory/../boot/string.c:99:20: warning: symbol 'simple_strtoull' was not declared. Should it be static?
> arch/x86/purgatory/../boot/string.c:128:8: warning: symbol 'strlen' was not declared. Should it be static?
> arch/x86/purgatory/../boot/string.c:142:6: warning: symbol 'strstr' was not declared. Should it be static?
>
> This patch has one checkpatch warning about the use of simple_strtoul which
> is obsolete. As this is an independent implementation it is not clear if
> the changes made in simple_strtoul -> _kstrtoull might also need to be
> applied here ?
>
> Patch was compile tested with: x86_64_defconfig
>
> Patch is against 4.9.0 (localversion-next is next-20161223)
>
> arch/x86/boot/string.c | 1 +
> arch/x86/boot/string.h | 9 +++++++++
> 2 files changed, 10 insertions(+)
>
> diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
> index cc3bd58..9e240fc 100644
> --- a/arch/x86/boot/string.c
> +++ b/arch/x86/boot/string.c
> @@ -14,6 +14,7 @@
>
> #include <linux/types.h>
> #include "ctype.h"
> +#include "string.h"
>
> int memcmp(const void *s1, const void *s2, size_t len)
> {
> diff --git a/arch/x86/boot/string.h b/arch/x86/boot/string.h
> index 725e820..f6ee139 100644
> --- a/arch/x86/boot/string.h
> +++ b/arch/x86/boot/string.h
> @@ -18,4 +18,13 @@ int memcmp(const void *s1, const void *s2, size_t len);
> #define memset(d,c,l) __builtin_memset(d,c,l)
> #define memcmp __builtin_memcmp
>
> +int strcmp(const char *str1, const char *str2);
> +int strncmp(const char *cs, const char *ct, size_t count);
> +size_t strlen(const char *s);
> +char *strstr(const char *s1, const char *s2);
> +size_t strnlen(const char *s, size_t maxlen);
> +unsigned int atou(const char *s);
> +unsigned long long simple_strtoull(const char *cp,
> + char **endp, unsigned int base);
Looks good to me, but please also mark them 'extern' to highlight the API
declarations like the rest of the kernel does - such as kernel.h which has
the kernel's simple_strtoull() declaration, etc.
It's not required syntactically, but it's a good stylistic principle to keep
external APIs organized.
Thanks,
Ingo
[toc] | [next] | [standalone]
| From | Nicholas Mc Guire <der.herr@hofr.at> |
|---|---|
| Date | 2017-01-07 10:40 +0100 |
| Message-ID | <sWVDH-6Q3-5@gated-at.bofh.it> |
| In reply to | #1551729 |
On Thu, Jan 05, 2017 at 09:02:09AM +0100, Ingo Molnar wrote:
>
> * Nicholas Mc Guire <hofrat@osadl.org> wrote:
>
> > Add the missing declarations of basic string functions to string.h to allow
> > a clean build.
> >
> > Fixes: commit 5be865661516 ("String-handling functions for the new x86 setup code.")
> > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> > ---
> >
> > sparse issues a set of warnings about missing declarations:
> > arch/x86/purgatory/../boot/string.c:18:5: warning: symbol 'memcmp' was not declared. Should it be static?
> > arch/x86/purgatory/../boot/string.c:26:5: warning: symbol 'strcmp' was not declared. Should it be static?
> > arch/x86/purgatory/../boot/string.c:42:5: warning: symbol 'strncmp' was not declared. Should it be static?
> > arch/x86/purgatory/../boot/string.c:58:8: warning: symbol 'strnlen' was not declared. Should it be static?
> > arch/x86/purgatory/../boot/string.c:69:14: warning: symbol 'atou' was not declared. Should it be static?
> > arch/x86/purgatory/../boot/string.c:99:20: warning: symbol 'simple_strtoull' was not declared. Should it be static?
> > arch/x86/purgatory/../boot/string.c:128:8: warning: symbol 'strlen' was not declared. Should it be static?
> > arch/x86/purgatory/../boot/string.c:142:6: warning: symbol 'strstr' was not declared. Should it be static?
> >
> > This patch has one checkpatch warning about the use of simple_strtoul which
> > is obsolete. As this is an independent implementation it is not clear if
> > the changes made in simple_strtoul -> _kstrtoull might also need to be
> > applied here ?
> >
> > Patch was compile tested with: x86_64_defconfig
> >
> > Patch is against 4.9.0 (localversion-next is next-20161223)
> >
> > arch/x86/boot/string.c | 1 +
> > arch/x86/boot/string.h | 9 +++++++++
> > 2 files changed, 10 insertions(+)
> >
> > diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
> > index cc3bd58..9e240fc 100644
> > --- a/arch/x86/boot/string.c
> > +++ b/arch/x86/boot/string.c
> > @@ -14,6 +14,7 @@
> >
> > #include <linux/types.h>
> > #include "ctype.h"
> > +#include "string.h"
> >
> > int memcmp(const void *s1, const void *s2, size_t len)
> > {
> > diff --git a/arch/x86/boot/string.h b/arch/x86/boot/string.h
> > index 725e820..f6ee139 100644
> > --- a/arch/x86/boot/string.h
> > +++ b/arch/x86/boot/string.h
> > @@ -18,4 +18,13 @@ int memcmp(const void *s1, const void *s2, size_t len);
> > #define memset(d,c,l) __builtin_memset(d,c,l)
> > #define memcmp __builtin_memcmp
> >
> > +int strcmp(const char *str1, const char *str2);
> > +int strncmp(const char *cs, const char *ct, size_t count);
> > +size_t strlen(const char *s);
> > +char *strstr(const char *s1, const char *s2);
> > +size_t strnlen(const char *s, size_t maxlen);
> > +unsigned int atou(const char *s);
> > +unsigned long long simple_strtoull(const char *cp,
> > + char **endp, unsigned int base);
>
> Looks good to me, but please also mark them 'extern' to highlight the API
> declarations like the rest of the kernel does - such as kernel.h which has
> the kernel's simple_strtoull() declaration, etc.
>
> It's not required syntactically, but it's a good stylistic principle to keep
> external APIs organized.
>
thanks - added the externs and resent as V2
while this does looks consistent with other kernel header files now
checkpatch --strict will issue CHECK requests of the form:
"CHECK: extern prototypes should be avoided in .h files"
so I just wonder if this CHECK is actually consistent with coding practice ?
the argument in commit 70dc8a48357c ("checkpatch: warn when using extern with function prototypes in .h files")
being:
<snip>
Using the extern keyword on function prototypes is superfluous visual
noise so suggest removing it.
Using extern can cause unnecessary line wrapping at 80 columns and
unnecessarily long multi-line function prototypes.
<anip>
thx!
hofrat
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web