+Fri Mar 16 16:01:54 CET 2007 Daniel Veillard <veillard@redhat.com>
+
+ * qemud/conf.c qemud/driver.h qemud/internal.h src/internal.h
+ src/sexpr.h src/test.c src/xm_internal.c src/xml.c src/xml.h:
+ applied patch from Richard Jones adding check to printf-like
+ functions and fixing the problems raised
+
Fri Mar 16 15:55:01 CET 2007 Daniel Veillard <veillard@redhat.com>
* src/xml.c tests/sexpr2xmltest.c tests/xmconfigtest.c: avoid
towrite = strlen(xml);
if (write(fd, xml, towrite) != towrite) {
qemudReportError(server, VIR_ERR_INTERNAL_ERROR,
- "cannot write config file %s",
+ "cannot write config file %s: %s",
network->configFile, strerror(errno));
goto cleanup;
}
if (close(fd) < 0) {
qemudReportError(server, VIR_ERR_INTERNAL_ERROR,
- "cannot save config file %s",
+ "cannot save config file %s: %s",
network->configFile, strerror(errno));
goto cleanup;
}
#include "internal.h"
void qemudReportError(struct qemud_server *server,
- int code, const char *fmt, ...);
+ int code, const char *fmt, ...)
+ ATTRIBUTE_FORMAT(printf,3,4);
int qemudGetCPUInfo(unsigned int *cpus, unsigned int *mhz,
unsigned int *nodes, unsigned int *sockets,
#include <ansidecl.h>
#endif
#ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED __attribute__((unused))
+#define ATTRIBUTE_UNUSED __attribute__((__unused__))
#endif
#ifndef ATTRIBUTE_FORMAT
#define ATTRIBUTE_FORMAT(args...) __attribute__((__format__ (args)))
int qemudShutdownNetworkDaemon(struct qemud_server *server,
struct qemud_network *network);
-void qemudLog(int priority, const char *fmt, ...);
+void qemudLog(int priority, const char *fmt, ...)
+ ATTRIBUTE_FORMAT(printf,2,3);
#ifdef ENABLE_DEBUG
#define qemudDebug(...) qemudLog(QEMUD_DEBUG, __VA_ARGS__)
#else
-#define qemudDebug(fmt, ...) do { } while(0);
+#define qemudDebug(fmt, ...) do {} while(0)
#endif
static inline int
#define _N(str) dgettext(GETTEXT_PACKAGE, (str))
#define gettext_noop(str) (str)
+#ifdef __GNUC__
+#ifdef HAVE_ANSIDECL_H
+#include <ansidecl.h>
+#endif
+
/**
* ATTRIBUTE_UNUSED:
*
* Macro to flag conciously unused parameters to functions
*/
-#ifdef __GNUC__
-#ifdef HAVE_ANSIDECL_H
-#include <ansidecl.h>
-#endif
#ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED __attribute__((unused))
+#define ATTRIBUTE_UNUSED __attribute__((__unused__))
#endif
-#else
-#define ATTRIBUTE_UNUSED
+
+/**
+ * ATTRIBUTE_FORMAT
+ *
+ * Macro used to check printf/scanf-like functions, if compiling
+ * with gcc.
+ */
+#ifndef ATTRIBUTE_FORMAT
+#define ATTRIBUTE_FORMAT(args...) __attribute__((__format__ (args)))
#endif
-#ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-# define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
- are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-# define __format__ format
-# define __printf__ printf
-# endif
+#else
+#define ATTRIBUTE_UNUSED
+#define ATTRIBUTE_FORMAT(...)
#endif
/**
const char *str1,
const char *str2,
const char *str3,
- int int1, int int2, const char *msg, ...);
+ int int1, int int2, const char *msg, ...)
+ ATTRIBUTE_FORMAT(printf, 12, 13);
const char *__virErrorMsg(virErrorNumber error, const char *info);
/************************************************************************
#ifndef _LIBVIR_SEXPR_H_
#define _LIBVIR_SEXPR_H_
+#include "internal.h"
+
#include <sys/types.h>
enum sexpr_type {
/* lookup in S-Expressions */
const char *sexpr_node(struct sexpr *sexpr, const char *node);
-const char *sexpr_fmt_node(struct sexpr *sexpr, const char *fmt, ...);
+const char *sexpr_fmt_node(struct sexpr *sexpr, const char *fmt, ...)
+ ATTRIBUTE_FORMAT(printf,2,3);
struct sexpr *sexpr_lookup(struct sexpr *sexpr, const char *node);
#endif
uuid[8], uuid[9], uuid[10], uuid[11],
uuid[12], uuid[13], uuid[14], uuid[15]);
- virBufferVSprintf(buf, " <memory>%d</memory>\n", con->domains[domidx].info.maxMem);
+ virBufferVSprintf(buf, " <memory>%lu</memory>\n", con->domains[domidx].info.maxMem);
virBufferVSprintf(buf, " <vcpu>%d</vcpu>\n", con->domains[domidx].info.nrVirtCpu);
virBufferVSprintf(buf, " <on_reboot>%s</on_reboot>\n", testRestartFlagToString(con->domains[domidx].onReboot));
virBufferVSprintf(buf, " <on_poweroff>%s</on_poweroff>\n", testRestartFlagToString(con->domains[domidx].onPoweroff));
if (vnc) {
virBufferVSprintf(buf,
- " <graphics type='vnc' port='%d'",
+ " <graphics type='vnc' port='%ld'",
(vncunused ? -1 : 5900+vncdisplay));
if (vnclisten) {
virBufferVSprintf(buf, " listen='%s'", vnclisten);
if (port == -1)
virBufferAdd(buf, "(vncunused 1)", 13);
else if (port >= 5900)
- virBufferVSprintf(buf, "(vncdisplay %d)", port - 5900);
+ virBufferVSprintf(buf, "(vncdisplay %ld)", port - 5900);
xmlFree(vncport);
}
if (vnclisten != NULL) {
if (port == -1)
virBufferAdd(buf, "(vncunused 1)", 13);
else if (port >= 5900)
- virBufferVSprintf(buf, "(vncdisplay %d)", port - 5900);
+ virBufferVSprintf(buf, "(vncdisplay %ld)", port - 5900);
xmlFree(vncport);
}
if (vnclisten != NULL) {
if (boot_dev) {
if (xmlStrEqual(boot_dev, BAD_CAST "fd")) {
- virBufferVSprintf(buf, "(boot a)", (const char *) boot_dev);
+ virBufferVSprintf(buf, "(boot a)" /*, (const char *) boot_dev*/);
} else if (xmlStrEqual(boot_dev, BAD_CAST "cdrom")) {
- virBufferVSprintf(buf, "(boot d)", (const char *) boot_dev);
+ virBufferVSprintf(buf, "(boot d)" /*, (const char *) boot_dev*/);
} else if (xmlStrEqual(boot_dev, BAD_CAST "hd")) {
- virBufferVSprintf(buf, "(boot c)", (const char *) boot_dev);
+ virBufferVSprintf(buf, "(boot c)" /*, (const char *) boot_dev*/);
} else {
/* Any other type of boot dev is unsupported right now */
virXMLError(conn, VIR_ERR_XML_ERROR, NULL, 0);
#define __VIR_XML_H__
#include "libvirt/libvirt.h"
+#include "internal.h"
#ifdef __cplusplus
extern "C" {
virBufferPtr virBufferNew(unsigned int size);
void virBufferFree(virBufferPtr buf);
int virBufferAdd(virBufferPtr buf, const char *str, int len);
-int virBufferVSprintf(virBufferPtr buf, const char *format, ...);
+int virBufferVSprintf(virBufferPtr buf, const char *format, ...)
+ ATTRIBUTE_FORMAT(printf, 2, 3);
int virBufferStrcat(virBufferPtr buf, ...);
char *virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int xendConfigVersion);