All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: lists@fixnum.org, qemu-devel@nongnu.org
Cc: Wim Vander Schelden <wim@fixnum.org>, alex.bennee@linaro.org
Subject: Re: [Qemu-devel] [PATCH] linux-user: added fake open() for /proc/self/cmdline
Date: Tue, 17 Jun 2014 15:09:17 -0600	[thread overview]
Message-ID: <53A0AE7D.2090303@redhat.com> (raw)
In-Reply-To: <1402975019-19503-2-git-send-email-lists@fixnum.org>

[-- Attachment #1: Type: text/plain, Size: 2257 bytes --]

On 06/16/2014 09:16 PM, lists@fixnum.org wrote:
> From: Wim Vander Schelden <wim@fixnum.org>
> 
> ---

Missing a Signed-off-by declaration; without that legal hurdle, we are
unwilling to take the patch.

For more details: http://wiki.qemu.org/Contribute/SubmitAPatch

>  linux-user/syscall.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 49 insertions(+)

Run your patch through scripts/checkpatch.pl to flag many of the
complaints below.

> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index c134c32..f9fed3e 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -4947,6 +4947,54 @@ int host_to_target_waitstatus(int status)
>      return status;
>  }
>  
> +static int open_self_cmdline(void *cpu_env, int fd)
> +{
> +    int fd_orig = -1;
> +    bool word_skipped = false;
> +
> +    fd_orig = open("/proc/self/cmdline",  O_RDONLY);

Why a double space?

> +    if(fd_orig < 0) {

Wrong style - we use space after 'if'

> +        return fd_orig;
> +    }
> +
> +    while(true) {

and space after 'while'

> +        if(! word_skipped) {
> +            // Skip the first string, which is the path to qemu-*-static instead of the actual command.

/* */ comments instead of //; fit 80 columns.

> +            size_t command_length = strnlen(buf, sizeof(buf));
> +            if(command_length != sizeof(buf)) {
> +                // Null byte found, skip one string
> +                nb_read -= command_length + 1;
> +                cp_buf += command_length + 1;
> +                word_skipped = true;

This feels a bit complicated.  Why not just use memchr() to locate the
first NUL byte, rather than messing with strnlen()?

> @@ -5148,6 +5196,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode)
>          { "maps", open_self_maps, is_proc_myself },
>          { "stat", open_self_stat, is_proc_myself },
>          { "auxv", open_self_auxv, is_proc_myself },
> +        { "cmdline", open_self_cmdline, is_proc_myself},

Match the style of the lines nearby (space before '}')

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-06-17 21:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-17  3:16 [Qemu-devel] [PATCH] linux-user: added fake open() for /proc/self/cmdline lists
2014-06-17  3:16 ` lists
2014-06-17 21:09   ` Eric Blake [this message]
2014-06-18  9:02     ` lists
2014-06-18  9:02       ` lists
2014-06-20 12:37         ` Riku Voipio

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=53A0AE7D.2090303@redhat.com \
    --to=eblake@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=lists@fixnum.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wim@fixnum.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.