Patchwork [2/6] qemu-ga: Drop pointless lseek() from ga_open_pidfile()

login
register
mail settings
Submitter Markus Armbruster
Date Jan. 11, 2013, 10:24 a.m.
Message ID <1357899902-5316-3-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/211287/
State New
Headers show

Comments

Markus Armbruster - Jan. 11, 2013, 10:24 a.m.
After open(), the file offset is already zero, and neither lockf() nor
ftruncate() change it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qga/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Michael Roth - Jan. 11, 2013, 5:41 p.m.
On Fri, Jan 11, 2013 at 11:24:58AM +0100, Markus Armbruster wrote:
> After open(), the file offset is already zero, and neither lockf() nor
> ftruncate() change it.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

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

> ---
>  qga/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qga/main.c b/qga/main.c
> index 47a6bea..1a22d8d 100644
> --- a/qga/main.c
> +++ b/qga/main.c
> @@ -276,7 +276,7 @@ static bool ga_open_pidfile(const char *pidfile)
>          return false;
>      }
> 
> -    if (ftruncate(pidfd, 0) || lseek(pidfd, 0, SEEK_SET)) {
> +    if (ftruncate(pidfd, 0)) {
>          g_critical("Failed to truncate pid file");
>          goto fail;
>      }
> -- 
> 1.7.11.7
>

Patch

diff --git a/qga/main.c b/qga/main.c
index 47a6bea..1a22d8d 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -276,7 +276,7 @@  static bool ga_open_pidfile(const char *pidfile)
         return false;
     }
 
-    if (ftruncate(pidfd, 0) || lseek(pidfd, 0, SEEK_SET)) {
+    if (ftruncate(pidfd, 0)) {
         g_critical("Failed to truncate pid file");
         goto fail;
     }