From: Paolo Bonzini <pbonzini@redhat.com>
To: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Alex Fishman <alex.fishman@ravellosystems.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
yvugenfi@redhat.com, Izik Eidus <izik.eidus@ravellosystems.com>,
qemu-devel@nongnu.org, Yan Vugenfirer <yan@daynix.com>,
Dmitry Fleytman <dmitry@daynix.com>
Subject: Re: [Qemu-devel] [PATCH 1/5] Utility function strpadcpy() added
Date: Thu, 15 Mar 2012 10:53:30 +0100 [thread overview]
Message-ID: <4F61BC1A.8020207@redhat.com> (raw)
In-Reply-To: <1331802150-12183-2-git-send-email-dmitry.fleytman@ravellosystems.com>
Il 15/03/2012 10:02, Dmitry Fleytman ha scritto:
> Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
> Signed-off-by: Yan Vugenfirer <yan@daynix.com>
> ---
> cutils.c | 13 +++++++++++++
> qemu-common.h | 1 +
> 2 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/cutils.c b/cutils.c
> index af308cd..0df7fdf 100644
> --- a/cutils.c
> +++ b/cutils.c
> @@ -27,6 +27,19 @@
>
> #include "qemu_socket.h"
>
> +void strpadcpy(char *buf, int buf_size, const char *str, char pad)
> +{
> + int i;
> + int has_src_data = TRUE;
> +
> + for (i = 0; i < buf_size; i++) {
> + if ((has_src_data) && (0 == str[i])) {
> + has_src_data = FALSE;
> + }
> + buf[i] = has_src_data ? str[i] : pad;
> + }
No parentheses around simple if conditions, this is not Pascal. :) But
since you're at it, why not the simpler:
int len = qemu_strnlen(str, buf_size);
memcpy(buf, str, len);
memset(buf + len, pad, buf_size - len);
> +}
> +
> void pstrcpy(char *buf, int buf_size, const char *str)
> {
> int c;
> diff --git a/qemu-common.h b/qemu-common.h
> index b0fdf5c..fdd3d17 100644
> --- a/qemu-common.h
> +++ b/qemu-common.h
> @@ -134,6 +134,7 @@ int qemu_timedate_diff(struct tm *tm);
>
> /* cutils.c */
> void pstrcpy(char *buf, int buf_size, const char *str);
> +void strpadcpy(char *buf, int buf_size, const char *str, char pad);
> char *pstrcat(char *buf, int buf_size, const char *s);
> int strstart(const char *str, const char *val, const char **ptr);
> int stristart(const char *str, const char *val, const char **ptr);
next prev parent reply other threads:[~2012-03-15 9:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-15 9:02 [Qemu-devel] [PATCH 0/5] VMWare PVSCSI paravirtual device implementation Dmitry Fleytman
2012-03-15 9:02 ` [Qemu-devel] [PATCH 1/5] Utility function strpadcpy() added Dmitry Fleytman
2012-03-15 9:53 ` Paolo Bonzini [this message]
2012-03-18 9:22 ` Dmitry Fleytman
2012-03-15 9:02 ` [Qemu-devel] [PATCH 2/5] Vendor name and product name parameters for SCSI devices Options "vendor_name" and "product_name" added for SCSI disks Dmitry Fleytman
2012-03-15 9:55 ` Paolo Bonzini
2012-03-18 9:24 ` Dmitry Fleytman
2012-03-15 9:02 ` [Qemu-devel] [PATCH 3/5] Header with various utility functions shared by VMWARE SCSI and network devices Dmitry Fleytman
2012-03-15 9:56 ` Paolo Bonzini
2012-03-18 9:23 ` Dmitry Fleytman
2012-03-15 9:02 ` [Qemu-devel] [PATCH 4/5] PVCSI paravirtualized device implementation Dmitry Fleytman
2012-03-15 9:02 ` [Qemu-devel] [PATCH 5/5] PVSCSI paravirtualized device integration Bus type "pvscsi" added Dmitry Fleytman
2012-03-15 9:46 ` Paolo Bonzini
2012-03-18 9:15 ` Dmitry Fleytman
2012-03-15 11:47 ` [Qemu-devel] [PATCH 0/5] VMWare PVSCSI paravirtual device implementation Stefan Hajnoczi
2012-03-15 11:54 ` Daniel P. Berrange
2012-03-15 11:54 ` Paolo Bonzini
2012-03-15 12:29 ` Avi Kivity
2012-03-18 8:31 ` Gerhard Wiesinger
2012-03-18 8:32 ` Gerhard Wiesinger
2012-03-18 12:33 ` Evgeny Budilovsky
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=4F61BC1A.8020207@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex.fishman@ravellosystems.com \
--cc=aliguori@us.ibm.com \
--cc=dmitry.fleytman@ravellosystems.com \
--cc=dmitry@daynix.com \
--cc=izik.eidus@ravellosystems.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yan@daynix.com \
--cc=yvugenfi@redhat.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).