diff mbox

[v2] qemu-ga: ga_open_pidfile(): add new line to pidfile

Message ID 20121003184001.219ab404@doriath.home
State New
Headers show

Commit Message

Luiz Capitulino Oct. 3, 2012, 9:40 p.m. UTC
FHS requires that pid files should end with a new line. Also change to
snprintf() while there.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---

o v2

 - use snprintf()
 - re-word changelog

 qemu-ga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Roth Oct. 4, 2012, 3:48 p.m. UTC | #1
On Wed, Oct 03, 2012 at 06:40:01PM -0300, Luiz Capitulino wrote:
> FHS requires that pid files should end with a new line. Also change to
> snprintf() while there.
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

> ---
> 
> o v2
> 
>  - use snprintf()
>  - re-word changelog
> 
>  qemu-ga.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qemu-ga.c b/qemu-ga.c
> index b747470..e4026f8 100644
> --- a/qemu-ga.c
> +++ b/qemu-ga.c
> @@ -255,7 +255,7 @@ static bool ga_open_pidfile(const char *pidfile)
>          g_critical("Failed to truncate pid file");
>          goto fail;
>      }
> -    sprintf(pidstr, "%d", getpid());
> +    snprintf(pidstr, sizeof(pidstr), "%d\n", getpid());
>      if (write(pidfd, pidstr, strlen(pidstr)) != strlen(pidstr)) {
>          g_critical("Failed to write pid file");
>          goto fail;
> -- 
> 1.7.12.315.g682ce8b
>
diff mbox

Patch

diff --git a/qemu-ga.c b/qemu-ga.c
index b747470..e4026f8 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -255,7 +255,7 @@  static bool ga_open_pidfile(const char *pidfile)
         g_critical("Failed to truncate pid file");
         goto fail;
     }
-    sprintf(pidstr, "%d", getpid());
+    snprintf(pidstr, sizeof(pidstr), "%d\n", getpid());
     if (write(pidfd, pidstr, strlen(pidstr)) != strlen(pidstr)) {
         g_critical("Failed to write pid file");
         goto fail;