From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx0mU-0005th-Em for qemu-devel@nongnu.org; Tue, 17 Jun 2014 17:19:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wx0mQ-00075a-FP for qemu-devel@nongnu.org; Tue, 17 Jun 2014 17:19:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47459) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx0mQ-00075S-7f for qemu-devel@nongnu.org; Tue, 17 Jun 2014 17:18:58 -0400 Message-ID: <53A0AE7D.2090303@redhat.com> Date: Tue, 17 Jun 2014 15:09:17 -0600 From: Eric Blake MIME-Version: 1.0 References: <1402975019-19503-1-git-send-email-lists@fixnum.org> <1402975019-19503-2-git-send-email-lists@fixnum.org> In-Reply-To: <1402975019-19503-2-git-send-email-lists@fixnum.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="1RiNRWaesJDd2AUjHBHPIbWOJmujjK9Pv" Subject: Re: [Qemu-devel] [PATCH] linux-user: added fake open() for /proc/self/cmdline List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: lists@fixnum.org, qemu-devel@nongnu.org Cc: Wim Vander Schelden , alex.bennee@linaro.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --1RiNRWaesJDd2AUjHBHPIbWOJmujjK9Pv Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 06/16/2014 09:16 PM, lists@fixnum.org wrote: > From: Wim Vander Schelden >=20 > --- 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. >=20 > 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; > } > =20 > +static int open_self_cmdline(void *cpu_env, int fd) > +{ > + int fd_orig =3D -1; > + bool word_skipped =3D false; > + > + fd_orig =3D 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-*-stat= ic instead of the actual command. /* */ comments instead of //; fit 80 columns. > + size_t command_length =3D strnlen(buf, sizeof(buf)); > + if(command_length !=3D sizeof(buf)) { > + // Null byte found, skip one string > + nb_read -=3D command_length + 1; > + cp_buf +=3D command_length + 1; > + word_skipped =3D 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 *pat= hname, 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 '}') --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --1RiNRWaesJDd2AUjHBHPIbWOJmujjK9Pv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJToK59AAoJEKeha0olJ0NqXmUIAIlh5zxtDCW62lvsEtvSCbxU MEPC6i8wl17Kq6fm5U3arPig0PIT6OHhxQim3Em2P5TVRr5cKLlzqMk1uw5nmKFm 9eJph8cD8amV1s/nGnLdU+DOJLDxBzWvL0mh5Rl8p9f0w2JD2fcm7M8yl8tQnLVi m26i+KV5gTeJr8NF5be/CXymfNExx4XVUQYIVb8BjZOt7fjUbf3DF5dyxJuSYsNo DT4u/1C+RUb4kIsHZDjUJr6L7LOrtekelzSx69VhCfFu5MKqnsSw5VS1X9Hpxqpr 0xkEcHAPwJmwmKLgibHA+Axw1Llv4uNde0+0Q74u0TmeQSIGAg5TKpUGcKmPiow= =xS3c -----END PGP SIGNATURE----- --1RiNRWaesJDd2AUjHBHPIbWOJmujjK9Pv--