From: Chen Gang <gang.chen@asianux.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: David Howells <dhowells@redhat.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
jang@linux.vnet.ibm.com, linux390@de.ibm.com,
linux-s390@vger.kernel.org,
Linux-Arch <linux-arch@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH v2] arch: s390: appldata: using strncpy() and strnlen() instead of sprintf()
Date: Wed, 29 May 2013 15:29:01 +0800 [thread overview]
Message-ID: <51A5AE3D.5080106@asianux.com> (raw)
In-Reply-To: <20130529063020.GG23932@mwanda>
On 05/29/2013 02:30 PM, Dan Carpenter wrote:
> On Wed, May 29, 2013 at 09:28:43AM +0800, Chen Gang wrote:
>
>> > diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
>> > index bae0f40..27f200d 100644
>> > --- a/arch/s390/appldata/appldata_base.c
>> > +++ b/arch/s390/appldata/appldata_base.c
>> > @@ -212,10 +212,9 @@ appldata_timer_handler(ctl_table *ctl, int write,
>> > return 0;
>> > }
>> > if (!write) {
>> > - len = sprintf(buf, appldata_timer_active ? "1\n" : "0\n");
>> > - if (len > *lenp)
>> > - len = *lenp;
>> > - if (copy_to_user(buffer, buf, len))
>> > + if (copy_to_user(buffer,
>> > + appldata_timer_active ? "1\n" : "0\n",
>> > + min(2, *lenp))
> I don't have a cross compiler set up, but this will generate a
> warning, I think. min_t() is needed.
Yes, it even can not pass compiling: need additional ')' for 'if'.
The new fix is below, (for pass compiling, also need fix the incorrect
declaration, which I have already sent an individual patch for it).
-----------------------------diff v2 begin------------------------------
diff --git a/arch/s390/appldata/appldata_base.c
b/arch/s390/appldata/appldata_base.c
index bae0f40..b0915b4 100644
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -212,10 +212,9 @@ appldata_timer_handler(ctl_table *ctl, int write,
return 0;
}
if (!write) {
- len = sprintf(buf, appldata_timer_active ? "1\n" : "0\n");
- if (len > *lenp)
- len = *lenp;
- if (copy_to_user(buffer, buf, len))
+ if (copy_to_user(buffer,
+ appldata_timer_active ? "1\n" : "0\n",
+ min_t(size_t, 2, *lenp)))
return -EFAULT;
goto out;
}
diff --git a/arch/s390/include/asm/pgtable.h
b/arch/s390/include/asm/pgtable.h
index 172209c..ed88890 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -1348,7 +1348,7 @@ static inline pmd_t pmd_mkwrite(pmd_t pmd)
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
#define __HAVE_ARCH_PGTABLE_DEPOSIT
-extern void pgtable_trans_huge_deposit(struct mm_struct *mm, , pmd_t *pmdp,
+extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
pgtable_t pgtable);
#define __HAVE_ARCH_PGTABLE_WITHDRAW
-----------------------------diff v2 end--------------------------------
For cross compiler, I use fedora 16/17, can yum update binutils-*
to get many platform cross-compilers (s390, powerpc, arm, xtensa, ...).
Thanks.
--
Chen Gang
Asianux Corporation
next prev parent reply other threads:[~2013-05-29 7:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-27 2:59 [PATCH] arch: s390: appldata: using strncpy() instead of sprintf() Chen Gang
2013-05-27 8:34 ` Geert Uytterhoeven
2013-05-27 9:06 ` Chen Gang
2013-05-27 9:43 ` [PATCH] arch: s390: include: asm: typo issue for the redundency comma, found by cross compiling Chen Gang
2013-05-27 9:55 ` [PATCH v2] arch: s390: appldata: using strncpy() and strnlen() instead of sprintf() Chen Gang
2013-05-27 16:23 ` Gerald Schaefer
2013-05-28 4:58 ` Chen Gang
2013-05-28 10:22 ` David Howells
2013-05-28 11:03 ` Chen Gang
2013-05-28 12:17 ` David Howells
2013-05-28 16:03 ` Gerald Schaefer
2013-05-29 1:40 ` Chen Gang
2013-05-29 1:28 ` Chen Gang
2013-05-29 6:30 ` Dan Carpenter
2013-05-29 7:29 ` Chen Gang [this message]
2013-05-29 7:47 ` Chen Gang
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=51A5AE3D.5080106@asianux.com \
--to=gang.chen@asianux.com \
--cc=dan.carpenter@oracle.com \
--cc=dhowells@redhat.com \
--cc=geert@linux-m68k.org \
--cc=heiko.carstens@de.ibm.com \
--cc=jang@linux.vnet.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux390@de.ibm.com \
--cc=schwidefsky@de.ibm.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