All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxc: Fix buffer length for get_suspend_file
@ 2014-03-18 13:54 Ian Jackson
  2014-03-18 13:56 ` Ian Campbell
  2014-03-18 13:58 ` [PATCH v2] " Ian Jackson
  0 siblings, 2 replies; 7+ messages in thread
From: Ian Jackson @ 2014-03-18 13:54 UTC (permalink / raw)
  To: xen-devel; +Cc: Julien Grall, Ian Jackson, Ian Campbell

Declaring a formal parameter to have an array type doesn't result in
the parameter actually having an array type.  The type is "adjusted"
to a pointer.  (C99 6.9.1(7), 6.7.5.3.)

So the use of sizeof in xc_suspend.c:get_suspend_file was wrong.
Instead, use the #define.  Also get rid of the array parameter, as it
is misleading.

Newer versions of gcc warn about the erroneous code:
  xc_suspend.c:39:25: error: argument to 'sizeof' in 'snprintf' call
    is the same expression as the destination; did you mean to provide
    an explicit length? [-Werror=sizeof-pointer-memaccess]

Reported-By: Julien Grall <julien.grall@linaro.org>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Julien Grall <julien.grall@linaro.org>
---
 tools/libxc/xc_suspend.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxc/xc_suspend.c b/tools/libxc/xc_suspend.c
index 84ee139..798eaaa 100644
--- a/tools/libxc/xc_suspend.c
+++ b/tools/libxc/xc_suspend.c
@@ -36,7 +36,7 @@
 
 static void get_suspend_file(char buf[SUSPEND_FILE_BUFLEN], int domid)
 {
-    snprintf(buf, sizeof(buf), SUSPEND_LOCK_FILE, domid);
+    snprintf(buf, SUSPEND_FILE_BUFLEN, SUSPEND_LOCK_FILE, domid);
 }
 
 static int lock_suspend_event(xc_interface *xch, int domid, int *lockfd)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-03-18 14:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-18 13:54 [PATCH] libxc: Fix buffer length for get_suspend_file Ian Jackson
2014-03-18 13:56 ` Ian Campbell
2014-03-18 13:58   ` Ian Jackson
2014-03-18 13:58 ` [PATCH v2] " Ian Jackson
2014-03-18 14:00   ` Ian Campbell
2014-03-18 14:10     ` Ian Jackson
2014-03-18 14:00   ` Julien Grall

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.