[Spice-commits] 15 commits - AUTHORS cfg.mk client/application.cpp client/client_net_socket.cpp client/cmd_line_parser.cpp client/hot_keys.cpp client/Makefile.am client/platform.h client/red_channel.cpp client/red_peer.cpp client/utils.h configure.ac m4/manywarnings.m4 m4/spice-compile-warnings.m4 m4/warnings.m4 .mailmap server/dispatcher.c server/glz_encoder_config.h server/reds.c server/red_worker.c server/smartcard.c server/tests
Daniel P. Berrange
berrange at kemper.freedesktop.org
Wed Apr 25 01:50:25 PDT 2012
.mailmap | 1
AUTHORS | 6
cfg.mk | 6
client/Makefile.am | 4
client/application.cpp | 2
client/client_net_socket.cpp | 2
client/cmd_line_parser.cpp | 2
client/hot_keys.cpp | 4
client/platform.h | 2
client/red_channel.cpp | 2
client/red_peer.cpp | 2
client/utils.h | 2
configure.ac | 77 ----------
m4/manywarnings.m4 | 184 +++++++++++++++++++++++++
m4/spice-compile-warnings.m4 | 162 ++++++++++++++++++++++
m4/warnings.m4 | 37 +++++
server/dispatcher.c | 12 -
server/glz_encoder_config.h | 6
server/red_worker.c | 75 +++++-----
server/reds.c | 9 -
server/smartcard.c | 11 -
server/tests/test_display_base.c | 4
server/tests/test_display_resolution_changes.c | 2
23 files changed, 464 insertions(+), 150 deletions(-)
New commits:
commit e71cb836806ccac249e3efcb7fa372f92aecc2da
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Wed Apr 25 09:22:56 2012 +0100
Ensure config.h is the first include in the file
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/server/tests/test_display_resolution_changes.c b/server/tests/test_display_resolution_changes.c
index edf7fb2..ef26ee1 100644
--- a/server/tests/test_display_resolution_changes.c
+++ b/server/tests/test_display_resolution_changes.c
@@ -2,8 +2,8 @@
* Recreate the primary surface endlessly.
*/
-#include <math.h>
#include <config.h>
+#include <math.h>
#include <stdlib.h>
#include "test_display_base.h"
commit f056a53b99623626723e977e2996d8d350bd3ea1
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Wed Apr 25 09:22:21 2012 +0100
Add a few more syntax-check exemptions
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/cfg.mk b/cfg.mk
index b7cd140..7cf1d58 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -136,7 +136,7 @@ exclude_file_name_regexp--sc_preprocessor_indentation = ^*/*.[ch]
exclude_file_name_regexp--sc_const_long_option = ^common/win/my_getopt-1.5/getopt.(3|txt)
-exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = ^common/win/my_getopt-1.5/getopt.(3|txt)|client/windows/(spice.ico|sticky_alt.bmp)|client/tests/controller_test/build
+exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = ^common/win/my_getopt-1.5/getopt.(3|txt)|client/windows/(spice.ico|sticky_alt.bmp)|client/tests/controller_test/build|docs/.*.odt|server/tests/base_test.ppm
# XXX this should be removed & all cases fixde
exclude_file_name_regexp--sc_prohibit_have_config_h = ^*/.*(c|cpp|h)
@@ -145,6 +145,8 @@ exclude_file_name_regexp--sc_require_config_h = ^client/gui/.*\.(ttf|font)\.c|cl
exclude_file_name_regexp--sc_require_config_h_first = ^client/gui/.*\.(ttf|font)\.c|client/gui/taharez.*\.c|client/x11/images/(alt_image|red_icon)\.c|common/win/my_getopt-1.5
-exclude_file_name_regexp--sc_trailing_blank = ^common/win/my_getopt-1.5/getopt.3
+exclude_file_name_regexp--sc_trailing_blank = ^common/win/my_getopt-1.5/getopt.3|docs/.*.odt
exclude_file_name_regexp--sc_unmarked_diagnostics = ^.*\.(c|py|h)
+
+exclude_file_name_regexp--sc_prohibit_path_max_allocation = server/tests/test_display_base.c
commit 8646341983be5b21e034701dcceb12ab3d09fe00
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Wed Apr 25 09:21:53 2012 +0100
Add recent new committers to AUTHORS file / mailmap
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/.mailmap b/.mailmap
index ef99211..4daed49 100644
--- a/.mailmap
+++ b/.mailmap
@@ -2,3 +2,4 @@
<cfergeau at redhat.com> <cfergeau at gmail.com>
<yhalperi at redhat.com> <yhalperi at yhalperi.tlv.redhat.com>
<alexl at redhat.com> <Larsson at .(none)>
+<nshalman at elys.com> <nshalman-github at elys.com>
diff --git a/AUTHORS b/AUTHORS
index 6fe2e88..230387e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -18,13 +18,19 @@ Previous Spice maintainers were
Patches also contributed by
Alexander Larsson <alexl at redhat.com>
+ Aric Stewart <aric at codeweavers.com>
Arnon Gilboa <agilboa at redhat.com>
Daniel P. Berrange <berrange at redhat.com>
Dan Kenigsberg <danken at redhat.com>
+ Dan McGee <dpmcgee at gmail.com>
+ Erlon Cruz <erlon.cruz at br.flextronics.com>
+ Fabiano Fidêncio <fabiano at fidencio.org>
Gal Hammer <ghammer at redhat.com>
Hans de Goede <hdegoede at redhat.com>
Jürg Billeter <j at bitron.ch>
Liang Guo <bluestonechina at gmail.com>
+ Michael Tokarev <mjt at tls.msk.ru>
+ Nahum Shalman <nshalman at elys.com>
Søren Sandmann Pedersen <ssp at redhat.com>
Thomas Tyminski <thomast at cs.tu-berlin.de>
Tiziano Mueller <dev-zero at gentoo.org>
commit d986fb466bb60c5e6229086261b6b3ed0b383d92
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Thu Mar 15 10:40:43 2012 +0000
Enable many more compiler warnings
* m4/manywarnings.m4m, m4/warnings.m4: Import GNULIB warnings
modules
* m4/spice-compile-warnings.m4: Define SPICE_COMPILE_WARNINGS
* configure.ac: Replace compile warning check with a call to
SPICE_COMPILE_WARNINGS
* client/Makefile.am: Use WARN_CXXFLAGS instead of WARN_CFLAGS
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/client/Makefile.am b/client/Makefile.am
index 22d5adf..ba3ce76 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -213,7 +213,7 @@ INCLUDES = \
$(SSL_CFLAGS) \
$(XRANDR_CFLAGS) \
$(XFIXES_CFLAGS) \
- $(WARN_CFLAGS) \
+ $(WARN_CXXFLAGS) \
$(XINERAMA_CFLAGS) \
$(CXIMAGE_CFLAGS) \
$(NULL)
diff --git a/configure.ac b/configure.ac
index 1feb36d..f5b014f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -394,82 +394,7 @@ fi
dnl ===========================================================================
dnl check compiler flags
-AC_DEFUN([SPICE_CC_TRY_FLAG], [
- AC_MSG_CHECKING([whether $CC supports $1])
-
- spice_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $1"
-
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([ ])], [spice_cc_flag=yes], [spice_cc_flag=no])
- CFLAGS="$spice_save_CFLAGS"
-
- if test "x$spice_cc_flag" = "xyes"; then
- ifelse([$2], , :, [$2])
- else
- ifelse([$3], , :, [$3])
- fi
- AC_MSG_RESULT([$spice_cc_flag])
-])
-
-
-dnl Use lots of warning flags with with gcc and compatible compilers
-
-dnl Note: if you change the following variable, the cache is automatically
-dnl skipped and all flags rechecked. So there's no need to do anything
-dnl else. If for any reason you need to force a recheck, just change
-dnl MAYBE_WARN in an ignorable way (like adding whitespace)
-
-dnl MAYBE_WARN="-Wall -Wno-sign-compare -Werror -Wno-deprecated-declarations"
-
-if test "$red_target" = "windows"; then
- MAYBE_WARN="-Wall -Wno-sign-compare -Wno-deprecated-declarations"
-else
- MAYBE_WARN="-Wall -Wno-sign-compare -Wno-deprecated-declarations"
-fi
-
-AC_ARG_ENABLE(werror,
-AC_HELP_STRING([--enable-werror], [Use -Werror (if supported)]),
-set_werror="$enableval",[
-if test -f $srcdir/GITVERSION; then
- is_git_version=true
- set_werror=yes
-else
- set_werror=no
-fi
-])
-
-# invalidate cached value if MAYBE_WARN has changed
-if test "x$spice_cv_warn_maybe" != "x$MAYBE_WARN"; then
- unset spice_cv_warn_cflags
-fi
-AC_CACHE_CHECK([for supported warning flags], spice_cv_warn_cflags, [
- echo
- WARN_CFLAGS=""
-
- # Some warning options are not supported by all versions of
- # gcc, so test all desired options against the current
- # compiler.
- #
- # Note that there are some order dependencies
- # here. Specifically, an option that disables a warning will
- # have no net effect if a later option then enables that
- # warnings, (perhaps implicitly). So we put some grouped
- # options (-Wall and -Wextra) up front and the -Wno options
- # last.
-
- for W in $MAYBE_WARN; do
- SPICE_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"])
- done
- if test "$set_werror" != "no"; then
- SPICE_CC_TRY_FLAG(["-Werror"], [WARN_CFLAGS="$WARN_CFLAGS -Werror"])
- fi
-
- spice_cv_warn_cflags=$WARN_CFLAGS
- spice_cv_warn_maybe=$MAYBE_WARN
-
- AC_MSG_CHECKING([which warning flags were supported])])
-WARN_CFLAGS="$spice_cv_warn_cflags"
-SPICE_CFLAGS="$SPICE_CFLAGS $WARN_CFLAGS"
+SPICE_COMPILE_WARNINGS
# use ximage.h for win32 build if it is found (no package for mingw32 atm)
if test $os_win32 == "yes" ; then
diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
new file mode 100644
index 0000000..fd0e372
--- /dev/null
+++ b/m4/manywarnings.m4
@@ -0,0 +1,184 @@
+# manywarnings.m4 serial 3
+dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Simon Josefsson
+
+# gl_MANYWARN_COMPLEMENT(OUTVAR, LISTVAR, REMOVEVAR)
+# --------------------------------------------------
+# Copy LISTVAR to OUTVAR except for the entries in REMOVEVAR.
+# Elements separated by whitespace. In set logic terms, the function
+# does OUTVAR = LISTVAR \ REMOVEVAR.
+AC_DEFUN([gl_MANYWARN_COMPLEMENT],
+[
+ gl_warn_set=
+ set x $2; shift
+ for gl_warn_item
+ do
+ case " $3 " in
+ *" $gl_warn_item "*)
+ ;;
+ *)
+ gl_warn_set="$gl_warn_set $gl_warn_item"
+ ;;
+ esac
+ done
+ $1=$gl_warn_set
+])
+
+# gl_MANYWARN_ALL_GCC(VARIABLE)
+# -----------------------------
+# Add all documented GCC warning parameters to variable VARIABLE.
+# Note that you need to test them using gl_WARN_ADD if you want to
+# make sure your gcc understands it.
+AC_DEFUN([gl_MANYWARN_ALL_GCC],
+[
+ dnl First, check if -Wno-missing-field-initializers is needed.
+ dnl -Wmissing-field-initializers is implied by -W, but that issues
+ dnl warnings with GCC version before 4.7, for the common idiom
+ dnl of initializing types on the stack to zero, using { 0, }
+ AC_REQUIRE([AC_PROG_CC])
+ if test -n "$GCC"; then
+
+ dnl First, check -W -Werror -Wno-missing-field-initializers is supported
+ dnl with the current $CC $CFLAGS $CPPFLAGS.
+ AC_MSG_CHECKING([whether -Wno-missing-field-initializers is supported])
+ AC_CACHE_VAL([gl_cv_cc_nomfi_supported], [
+ gl_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -W -Werror -Wno-missing-field-initializers"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[]], [[]])],
+ [gl_cv_cc_nomfi_supported=yes],
+ [gl_cv_cc_nomfi_supported=no])
+ CFLAGS="$gl_save_CFLAGS"])
+ AC_MSG_RESULT([$gl_cv_cc_nomfi_supported])
+
+ if test "$gl_cv_cc_nomfi_supported" = yes; then
+ dnl Now check whether -Wno-missing-field-initializers is needed
+ dnl for the { 0, } construct.
+ AC_MSG_CHECKING([whether -Wno-missing-field-initializers is needed])
+ AC_CACHE_VAL([gl_cv_cc_nomfi_needed], [
+ gl_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -W -Werror"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[void f (void)
+ {
+ typedef struct { int a; int b; } s_t;
+ s_t s1 = { 0, };
+ }
+ ]],
+ [[]])],
+ [gl_cv_cc_nomfi_needed=no],
+ [gl_cv_cc_nomfi_needed=yes])
+ CFLAGS="$gl_save_CFLAGS"
+ ])
+ AC_MSG_RESULT([$gl_cv_cc_nomfi_needed])
+ fi
+ fi
+
+ gl_manywarn_set=
+ for gl_manywarn_item in \
+ -Wall \
+ -W \
+ -Wformat-y2k \
+ -Wformat-nonliteral \
+ -Wformat-security \
+ -Winit-self \
+ -Wmissing-include-dirs \
+ -Wswitch-default \
+ -Wswitch-enum \
+ -Wunused \
+ -Wunknown-pragmas \
+ -Wstrict-aliasing \
+ -Wstrict-overflow \
+ -Wsystem-headers \
+ -Wfloat-equal \
+ -Wtraditional \
+ -Wtraditional-conversion \
+ -Wdeclaration-after-statement \
+ -Wundef \
+ -Wshadow \
+ -Wunsafe-loop-optimizations \
+ -Wpointer-arith \
+ -Wbad-function-cast \
+ -Wc++-compat \
+ -Wcast-qual \
+ -Wcast-align \
+ -Wwrite-strings \
+ -Wconversion \
+ -Wsign-conversion \
+ -Wlogical-op \
+ -Waggregate-return \
+ -Wstrict-prototypes \
+ -Wold-style-definition \
+ -Wmissing-prototypes \
+ -Wmissing-declarations \
+ -Wmissing-noreturn \
+ -Wmissing-format-attribute \
+ -Wpacked \
+ -Wpadded \
+ -Wredundant-decls \
+ -Wnested-externs \
+ -Wunreachable-code \
+ -Winline \
+ -Winvalid-pch \
+ -Wlong-long \
+ -Wvla \
+ -Wvolatile-register-var \
+ -Wdisabled-optimization \
+ -Wstack-protector \
+ -Woverlength-strings \
+ -Wbuiltin-macro-redefined \
+ -Wmudflap \
+ -Wpacked-bitfield-compat \
+ -Wsync-nand \
+ ; do
+ gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
+ done
+ # The following are not documented in the manual but are included in
+ # output from gcc --help=warnings.
+ for gl_manywarn_item in \
+ -Wattributes \
+ -Wcoverage-mismatch \
+ -Wmultichar \
+ -Wunused-macros \
+ ; do
+ gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
+ done
+ # More warnings from gcc 4.6.2 --help=warnings.
+ for gl_manywarn_item in \
+ -Wabi \
+ -Wcpp \
+ -Wdeprecated \
+ -Wdeprecated-declarations \
+ -Wdiv-by-zero \
+ -Wdouble-promotion \
+ -Wendif-labels \
+ -Wextra \
+ -Wformat-contains-nul \
+ -Wformat-extra-args \
+ -Wformat-zero-length \
+ -Wformat=2 \
+ -Wmultichar \
+ -Wnormalized=nfc \
+ -Woverflow \
+ -Wpointer-to-int-cast \
+ -Wpragmas \
+ -Wsuggest-attribute=const \
+ -Wsuggest-attribute=noreturn \
+ -Wsuggest-attribute=pure \
+ -Wtrampolines \
+ ; do
+ gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
+ done
+
+ # Disable the missing-field-initializers warning if needed
+ if test "$gl_cv_cc_nomfi_needed" = yes; then
+ gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers"
+ fi
+
+ $1=$gl_manywarn_set
+])
diff --git a/m4/spice-compile-warnings.m4 b/m4/spice-compile-warnings.m4
new file mode 100644
index 0000000..8de2ffd
--- /dev/null
+++ b/m4/spice-compile-warnings.m4
@@ -0,0 +1,162 @@
+dnl
+dnl Enable all known GCC compiler warnings, except for those
+dnl we can't yet cope with
+dnl
+AC_DEFUN([SPICE_COMPILE_WARNINGS],[
+ dnl ******************************
+ dnl More compiler warnings
+ dnl ******************************
+
+ AC_ARG_ENABLE([werror],
+ AS_HELP_STRING([--enable-werror], [Use -Werror (if supported)]),
+ [set_werror="$enableval"],
+ [if test -d $srcdir/.git; then
+ is_git_version=true
+ set_werror=yes
+ else
+ set_werror=no
+ fi])
+
+ # List of warnings that are not relevant / wanted
+
+ # Don't care about C++ compiler compat
+ dontwarn="$dontwarn -Wc++-compat"
+ dontwarn="$dontwarn -Wabi"
+ dontwarn="$dontwarn -Wdeprecated"
+ # Don't care about ancient C standard compat
+ dontwarn="$dontwarn -Wtraditional"
+ # Don't care about ancient C standard compat
+ dontwarn="$dontwarn -Wtraditional-conversion"
+ # Ignore warnings in /usr/include
+ dontwarn="$dontwarn -Wsystem-headers"
+ # Happy for compiler to add struct padding
+ dontwarn="$dontwarn -Wpadded"
+ # GCC very confused with -O2
+ dontwarn="$dontwarn -Wunreachable-code"
+
+
+ dontwarn="$dontwarn -Wconversion"
+ dontwarn="$dontwarn -Wsign-conversion"
+ dontwarn="$dontwarn -Wvla"
+ dontwarn="$dontwarn -Wundef"
+ dontwarn="$dontwarn -Wcast-qual"
+ dontwarn="$dontwarn -Wlong-long"
+ dontwarn="$dontwarn -Wswitch-default"
+ dontwarn="$dontwarn -Wswitch-enum"
+ dontwarn="$dontwarn -Wstrict-overflow"
+ dontwarn="$dontwarn -Wunsafe-loop-optimizations"
+ dontwarn="$dontwarn -Wformat-nonliteral"
+ dontwarn="$dontwarn -Wfloat-equal"
+ dontwarn="$dontwarn -Wdeclaration-after-statement"
+ dontwarn="$dontwarn -Wcast-qual"
+ dontwarn="$dontwarn -Wconversion"
+ dontwarn="$dontwarn -Wsign-conversion"
+ dontwarn="$dontwarn -Wpacked"
+ dontwarn="$dontwarn -Wunused-macros"
+ dontwarn="$dontwarn -Woverlength-strings"
+ dontwarn="$dontwarn -Wstack-protector"
+ dontwarn="$dontwarn -Winline"
+ dontwarn="$dontwarn -Wbad-function-cast"
+ dontwarn="$dontwarn -Wshadow"
+
+ # We want to enable thse, but need to sort out the
+ # decl mess with gtk/generated_*.c
+ dontwarn="$dontwarn -Wmissing-prototypes"
+ dontwarn="$dontwarn -Wmissing-declarations"
+
+ # Stuff that C++ won't allow. Turn them back on later
+ dontwarn="$dontwarn -Waggregate-return"
+ dontwarn="$dontwarn -Wstrict-prototypes"
+ dontwarn="$dontwarn -Wold-style-definition"
+ dontwarn="$dontwarn -Wnested-externs"
+ dontwarn="$dontwarn -Wformat-zero-length"
+ dontwarn="$dontwarn -Wpointer-to-int-cast"
+ dontwarn="$dontwarn -Wjump-misses-init"
+
+ # Issues in x11/platform_utils.cpp prevent us turning this on
+ dontwarn="$dontwarn -Wmissing-format-attribute"
+
+ # Get all possible GCC warnings
+ gl_MANYWARN_ALL_GCC([maybewarn])
+
+ # Remove the ones we don't want, blacklisted earlier
+ gl_MANYWARN_COMPLEMENT([wantwarn], [$maybewarn], [$dontwarn])
+
+ # Check for $CC support of each warning
+ for w in $wantwarn; do
+ gl_WARN_ADD([$w])
+ done
+
+ # GNULIB uses '-W' (aka -Wextra) which includes a bunch of stuff.
+ # Unfortunately, this means you can't simply use '-Wsign-compare'
+ # with gl_MANYWARN_COMPLEMENT
+ # So we have -W enabled, and then have to explicitly turn off...
+ gl_WARN_ADD([-Wno-sign-compare])
+ gl_WARN_ADD([-Wno-unused-parameter])
+ # We can't enable this due to horrible spice_usb_device_get_description
+ # signature
+ gl_WARN_ADD([-Wno-format-nonliteral])
+ # CEGui headers cause violation of this
+ gl_WARN_ADD([-Wno-ignored-qualifiers])
+
+
+
+
+ # GNULIB turns on -Wformat=2 which implies -Wformat-nonliteral,
+ # so we need to manually re-exclude it.
+ gl_WARN_ADD([-Wno-format-nonliteral])
+
+ # This should be < 1024 really. pixman_utils is the blackspot
+ # preventing lower usage
+ gl_WARN_ADD([-Wframe-larger-than=20460])
+
+ # Use improved glibc headers
+ AC_DEFINE([_FORTIFY_SOURCE], [2],
+ [enable compile-time and run-time bounds-checking, and some warnings])
+
+ # Extra special flags
+ dnl -fstack-protector stuff passes gl_WARN_ADD with gcc
+ dnl on Mingw32, but fails when actually used
+ case $host in
+ *-*-linux*)
+ dnl Fedora only uses -fstack-protector, but doesn't seem to
+ dnl be great overhead in adding -fstack-protector-all instead
+ dnl gl_WARN_ADD([-fstack-protector])
+ gl_WARN_ADD([-fstack-protector-all])
+ gl_WARN_ADD([--param=ssp-buffer-size=4])
+ ;;
+ esac
+ gl_WARN_ADD([-fexceptions])
+ gl_WARN_ADD([-fasynchronous-unwind-tables])
+ gl_WARN_ADD([-fdiagnostics-show-option])
+ gl_WARN_ADD([-funit-at-a-time])
+
+ # Need -fipa-pure-const in order to make -Wsuggest-attribute=pure
+ # fire even without -O.
+ gl_WARN_ADD([-fipa-pure-const])
+
+ # We should eventually enable this, but right now there are at
+ # least 75 functions triggering warnings.
+ gl_WARN_ADD([-Wno-suggest-attribute=pure])
+ gl_WARN_ADD([-Wno-suggest-attribute=const])
+
+ if test "$set_werror" = "yes"
+ then
+ gl_WARN_ADD([-Werror])
+ fi
+ WARN_CXXFLAGS=$WARN_CFLAGS
+ AC_SUBST([WARN_CXXFLAGS])
+
+ # These are C-only warnings
+ gl_WARN_ADD([-Waggregate-return])
+ gl_WARN_ADD([-Wstrict-prototypes])
+ gl_WARN_ADD([-Wold-style-definition])
+ gl_WARN_ADD([-Wnested-externs])
+ gl_WARN_ADD([-Wformat-zero-length])
+ gl_WARN_ADD([-Wpointer-to-int-cast])
+ gl_WARN_ADD([-Wjump-misses-init])
+
+ WARN_LDFLAGS=$WARN_CFLAGS
+ AC_SUBST([WARN_CFLAGS])
+ AC_SUBST([WARN_LDFLAGS])
+])
diff --git a/m4/warnings.m4 b/m4/warnings.m4
new file mode 100644
index 0000000..69d05a6
--- /dev/null
+++ b/m4/warnings.m4
@@ -0,0 +1,37 @@
+# warnings.m4 serial 5
+dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Simon Josefsson
+
+# gl_AS_VAR_APPEND(VAR, VALUE)
+# ----------------------------
+# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.
+m4_ifdef([AS_VAR_APPEND],
+[m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])],
+[m4_define([gl_AS_VAR_APPEND],
+[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
+
+# gl_WARN_ADD(PARAMETER, [VARIABLE = WARN_CFLAGS])
+# ------------------------------------------------
+# Adds parameter to WARN_CFLAGS if the compiler supports it. For example,
+# gl_WARN_ADD([-Wparentheses]).
+AC_DEFUN([gl_WARN_ADD],
+dnl FIXME: gl_Warn must be used unquoted until we can assume
+dnl autoconf 2.64 or newer.
+[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_$1])dnl
+AC_CACHE_CHECK([whether compiler handles $1], m4_defn([gl_Warn]), [
+ gl_save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="${CPPFLAGS} $1"
+ AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
+ [AS_VAR_SET(gl_Warn, [yes])],
+ [AS_VAR_SET(gl_Warn, [no])])
+ CPPFLAGS="$gl_save_CPPFLAGS"
+])
+AS_VAR_IF(gl_Warn, [yes],
+ [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])])
+AS_VAR_POPDEF([gl_Warn])dnl
+m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
+])
commit 39565707a9b9b6460ca18c5c9749ae565d583e2a
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Mon Apr 2 11:55:51 2012 +0100
Make some int->pointer casts explicit
Tell the compiler that was really do intend to cast from int
to pointer, to prevent warnings about implicit casts
* server/tests/test_display_base.c: Add explicit casts
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/server/tests/test_display_base.c b/server/tests/test_display_base.c
index f6c3f6b..3e2ba6c 100644
--- a/server/tests/test_display_base.c
+++ b/server/tests/test_display_base.c
@@ -522,7 +522,7 @@ static void do_wakeup(void *opaque)
static void release_resource(QXLInstance *qin, struct QXLReleaseInfoExt release_info)
{
- QXLCommandExt *ext = (unsigned long)release_info.info->id;
+ QXLCommandExt *ext = (QXLCommandExt*)(unsigned long)release_info.info->id;
//printf("%s\n", __func__);
ASSERT(release_info.group_id == MEM_SLOT_GROUP_ID);
switch (ext->cmd.type) {
@@ -533,7 +533,7 @@ static void release_resource(QXLInstance *qin, struct QXLReleaseInfoExt release_
free(ext);
break;
case QXL_CMD_CURSOR: {
- QXLCursorCmd *cmd = (unsigned long)ext->cmd.data;
+ QXLCursorCmd *cmd = (QXLCursorCmd *)(unsigned long)ext->cmd.data;
if (cmd->type == QXL_CURSOR_SET) {
free(cmd);
}
commit e1633c65cc804708a2a3dc7b94650300be38f2bf
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Mon Apr 2 12:01:51 2012 +0100
Fix broken -I../common to be -I../spice-common in client
* Makefile.am: s/common/spice-common/
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/client/Makefile.am b/client/Makefile.am
index 4913c1e..22d5adf 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -199,7 +199,7 @@ endif
INCLUDES = \
-D__STDC_LIMIT_MACROS \
$(PLATFORM_INCLUDES) \
- -I$(top_srcdir)/common \
+ -I$(top_srcdir)/spice-common \
$(ALSA_CFLAGS) \
$(CEGUI_CFLAGS) \
$(CEGUI06_CFLAGS) \
commit 7af613362a2e320574dc688fad98294e90f029cc
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Tue Mar 13 16:39:45 2012 +0000
VSCMsgHeader.reader_id is unsigned, so don't check for >= 0
* server/smartcard.c: Fix assertion to not check for >= 0 on
unsigned variable
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/server/smartcard.c b/server/smartcard.c
index 805cb6e..eb2823a 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -428,8 +428,7 @@ static void smartcard_channel_write_to_reader(VSCMsgHeader *vheader)
uint32_t n;
uint32_t actual_length = vheader->length;
- spice_assert(vheader->reader_id >= 0 &&
- vheader->reader_id <= g_smartcard_readers.num);
+ spice_assert(vheader->reader_id <= g_smartcard_readers.num);
sin = g_smartcard_readers.sin[vheader->reader_id];
sif = SPICE_CONTAINEROF(sin->base.sif, SpiceCharDeviceInterface, base);
/* protocol requires messages to be in network endianess */
commit 84c7a95c22ba3a0fc5623c7cd66c9793e02ebcf8
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Tue Mar 13 16:11:03 2012 +0000
Avoid jumping across variables declarations with initializers
If a 'goto' statement jumps across a variable declaration
which also has an initializer, the variable is in an undefined
state. Splitting the the declaration & initialization doesn't
change that, but the compiler can at least now detect use of
the unintialized variable
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/server/reds.c b/server/reds.c
index 8ae569c..1696fbc 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3666,9 +3666,10 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
reds->vdi_port_write_timer_started = FALSE;
#ifdef RED_STATISTICS
- int shm_name_len = strlen(SPICE_STAT_SHM_NAME) + 20;
+ int shm_name_len;
int fd;
+ shm_name_len = strlen(SPICE_STAT_SHM_NAME) + 20;
reds->stat_shm_name = (char *)spice_malloc(shm_name_len);
snprintf(reds->stat_shm_name, shm_name_len, SPICE_STAT_SHM_NAME, getpid());
if ((fd = shm_open(reds->stat_shm_name, O_CREAT | O_RDWR, 0444)) == -1) {
commit 3be7df09800f8a823ec307830fd8d3f26f28ffc6
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Tue Mar 13 16:09:38 2012 +0000
Convert cases of () to (void)
* server/reds.c, server/smartcard.c: s/()/(void)
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/server/reds.c b/server/reds.c
index 53fc748..8ae569c 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1595,7 +1595,7 @@ static void reds_mig_target_client_free(RedsMigTargetClient *mig_client)
free(mig_client);
}
-static void reds_mig_target_client_disconnect_all()
+static void reds_mig_target_client_disconnect_all(void)
{
RingItem *now, *next;
diff --git a/server/smartcard.c b/server/smartcard.c
index 894053e..805cb6e 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -65,7 +65,7 @@ static struct Readers {
SpiceCharDeviceInstance* sin[SMARTCARD_MAX_READERS];
} g_smartcard_readers = {0, {NULL}};
-static SpiceCharDeviceInstance* smartcard_readers_get_unattached();
+static SpiceCharDeviceInstance* smartcard_readers_get_unattached(void);
static SpiceCharDeviceInstance* smartcard_readers_get(uint32_t reader_id);
static int smartcard_char_device_add_to_readers(SpiceCharDeviceInstance *sin);
static void smartcard_char_device_attach(
@@ -77,7 +77,7 @@ static void smartcard_char_device_on_message_from_device(
SmartCardDeviceState *state, VSCMsgHeader *header);
static void smartcard_on_message_from_device(
RedChannelClient *rcc, VSCMsgHeader *vheader);
-static SmartCardDeviceState* smartcard_device_state_new();
+static SmartCardDeviceState* smartcard_device_state_new(void);
static void smartcard_device_state_free(SmartCardDeviceState* st);
static void smartcard_init(void);
@@ -180,7 +180,7 @@ static SpiceCharDeviceInstance *smartcard_readers_get(uint32_t reader_id)
return g_smartcard_readers.sin[reader_id];
}
-static SpiceCharDeviceInstance *smartcard_readers_get_unattached()
+static SpiceCharDeviceInstance *smartcard_readers_get_unattached(void)
{
int i;
SmartCardDeviceState* state;
@@ -195,7 +195,7 @@ static SpiceCharDeviceInstance *smartcard_readers_get_unattached()
return NULL;
}
-static SmartCardDeviceState* smartcard_device_state_new()
+static SmartCardDeviceState* smartcard_device_state_new(void)
{
SmartCardDeviceState *st;
commit 93d8ca81916397a1398f136661123625b3df2727
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Tue Mar 13 16:05:23 2012 +0000
Remove 2 *MB* stack frame in red_worker_main
The red_worker_main method allocates a RedWorker struct instance
on the stack. This struct is a full 2 MB in size which is not
at all resonable to allocate on the stack.
* server/red_worker.c: Move RedWorker struct to the heap
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/server/red_worker.c b/server/red_worker.c
index 32d390d..fc74924 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -11134,7 +11134,7 @@ static void red_display_cc_free_glz_drawables(RedChannelClient *rcc)
SPICE_GNUC_NORETURN void *red_worker_main(void *arg)
{
- RedWorker worker;
+ RedWorker *worker = spice_malloc(sizeof(RedWorker));
spice_printerr("begin");
spice_assert(MAX_PIPE_SIZE > WIDE_CLIENT_ACK_WINDOW &&
@@ -11146,28 +11146,28 @@ SPICE_GNUC_NORETURN void *red_worker_main(void *arg)
}
#endif
- red_init(&worker, (WorkerInitData *)arg);
- red_init_quic(&worker);
- red_init_lz(&worker);
- red_init_jpeg(&worker);
- red_init_zlib(&worker);
- worker.event_timeout = INF_EVENT_WAIT;
+ red_init(worker, (WorkerInitData *)arg);
+ red_init_quic(worker);
+ red_init_lz(worker);
+ red_init_jpeg(worker);
+ red_init_zlib(worker);
+ worker->event_timeout = INF_EVENT_WAIT;
for (;;) {
int i, num_events;
- worker.event_timeout = MIN(red_get_streams_timout(&worker), worker.event_timeout);
- num_events = poll(worker.poll_fds, MAX_EVENT_SOURCES, worker.event_timeout);
- red_handle_streams_timout(&worker);
+ worker->event_timeout = MIN(red_get_streams_timout(worker), worker->event_timeout);
+ num_events = poll(worker->poll_fds, MAX_EVENT_SOURCES, worker->event_timeout);
+ red_handle_streams_timout(worker);
- if (worker.display_channel) {
+ if (worker->display_channel) {
/* during migration, in the dest, the display channel can be initialized
while the global lz data not since migrate data msg hasn't been
received yet */
- red_channel_apply_clients(&worker.display_channel->common.base,
- red_display_cc_free_glz_drawables);
+ red_channel_apply_clients(&worker->display_channel->common.base,
+ red_display_cc_free_glz_drawables);
}
- worker.event_timeout = INF_EVENT_WAIT;
+ worker->event_timeout = INF_EVENT_WAIT;
if (num_events == -1) {
if (errno != EINTR) {
spice_error("poll failed, %s", strerror(errno));
@@ -11178,33 +11178,33 @@ SPICE_GNUC_NORETURN void *red_worker_main(void *arg)
/* The watch may have been removed by the watch-func from
another fd (ie a disconnect through the dispatcher),
in this case watch_func is NULL. */
- if (worker.poll_fds[i].revents && worker.watches[i].watch_func) {
+ if (worker->poll_fds[i].revents && worker->watches[i].watch_func) {
int events = 0;
- if (worker.poll_fds[i].revents & POLLIN) {
+ if (worker->poll_fds[i].revents & POLLIN) {
events |= SPICE_WATCH_EVENT_READ;
}
- if (worker.poll_fds[i].revents & POLLOUT) {
+ if (worker->poll_fds[i].revents & POLLOUT) {
events |= SPICE_WATCH_EVENT_WRITE;
}
- worker.watches[i].watch_func(worker.poll_fds[i].fd, events,
- worker.watches[i].watch_func_opaque);
+ worker->watches[i].watch_func(worker->poll_fds[i].fd, events,
+ worker->watches[i].watch_func_opaque);
}
}
/* Clear the poll_fd for any removed watches, see the comment in
watch_remove for why we don't do this there. */
for (i = 0; i < MAX_EVENT_SOURCES; i++) {
- if (!worker.watches[i].watch_func) {
- worker.poll_fds[i].fd = -1;
+ if (!worker->watches[i].watch_func) {
+ worker->poll_fds[i].fd = -1;
}
}
- if (worker.running) {
+ if (worker->running) {
int ring_is_empty;
- red_process_cursor(&worker, MAX_PIPE_SIZE, &ring_is_empty);
- red_process_commands(&worker, MAX_PIPE_SIZE, &ring_is_empty);
+ red_process_cursor(worker, MAX_PIPE_SIZE, &ring_is_empty);
+ red_process_commands(worker, MAX_PIPE_SIZE, &ring_is_empty);
}
- red_push(&worker);
+ red_push(worker);
}
abort();
}
commit eeb2b65a7d5d79af3588ca5cf7e00c4ffd645ea7
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Tue Mar 13 16:05:12 2012 +0000
Mark some variables as volatile
When using setjmp/longjmp the state of local variables can be
undefined in certain scenarios:
[quote man(longjmp)]
The values of automatic variables are unspecified after a
call to longjmp() if they meet all the following criteria:
· they are local to the function that made the correspondâ
ing setjmp(3) call;
· their values are changed between the calls to setjmp(3)
and longjmp(); and
· they are not declared as volatile.
[/quote]
* server/red_worker.c: Mark some vars as volatile
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/server/red_worker.c b/server/red_worker.c
index 87118b6..32d390d 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -5926,9 +5926,9 @@ static int red_jpeg_compress_image(DisplayChannelClient *dcc, SpiceImage *dest,
LzData *lz_data = &worker->lz_data;
JpegEncoderContext *jpeg = worker->jpeg;
LzContext *lz = worker->lz;
- JpegEncoderImageType jpeg_in_type;
+ volatile JpegEncoderImageType jpeg_in_type;
int jpeg_size = 0;
- int has_alpha = FALSE;
+ volatile int has_alpha = FALSE;
int alpha_lz_size = 0;
int comp_head_filled;
int comp_head_left;
@@ -6066,7 +6066,7 @@ static inline int red_quic_compress_image(DisplayChannelClient *dcc, SpiceImage
RedWorker *worker = display_channel->common.worker;
QuicData *quic_data = &worker->quic_data;
QuicContext *quic = worker->quic;
- QuicImageType type;
+ volatile QuicImageType type;
int size, stride;
#ifdef COMPRESS_STAT
commit 456634a63ea6f409a5444e4aeeaaef1b7262034d
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Tue Mar 13 15:29:25 2012 +0000
Mark functions which never return control
* client/red_channel.cpp: AbortTrigger::on_event can't return
given its current impl
* server/red_worker.c: red_worker_main can't return
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/client/red_channel.cpp b/client/red_channel.cpp
index 5523abd..f585732 100644
--- a/client/red_channel.cpp
+++ b/client/red_channel.cpp
@@ -322,7 +322,7 @@ void SendTrigger::on_event()
_channel.on_send_trigger();
}
-void AbortTrigger::on_event()
+SPICE_GNUC_NORETURN void AbortTrigger::on_event()
{
THROW("abort");
}
diff --git a/server/red_worker.c b/server/red_worker.c
index 1a0438e..87118b6 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -11132,7 +11132,7 @@ static void red_display_cc_free_glz_drawables(RedChannelClient *rcc)
red_display_handle_glz_drawables_to_free(dcc);
}
-void *red_worker_main(void *arg)
+SPICE_GNUC_NORETURN void *red_worker_main(void *arg)
{
RedWorker worker;
@@ -11206,8 +11206,7 @@ void *red_worker_main(void *arg)
}
red_push(&worker);
}
- spice_printerr("exit");
- return 0;
+ abort();
}
#ifdef DUMP_BITMAP
commit 6a8b7585e2051baa911b665ed713835bc65515d6
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Tue Mar 13 15:28:26 2012 +0000
Fix multiple printf format problems
All printf var-args style methods should be annotation with
their format. All format strings must be const strings.
* client/application.cpp, client/cmd_line_parser.cpp,
client/hot_keys.cpp: Avoid non-const format
* client/client_net_socket.cpp: Fix broken format specifier
* client/red_peer.cpp: Fix missing format specifier
* client/platform.h: Add SPICE_GNUC_PRINTF annotation to term_printf
* client/utils.h: Add SPICE_GNUC_PRINTF annotation to string_printf
* server/glz_encoder_config.h, server/red_worker.c: Add
SPICE_GNUC_PRINTF annotation to warning callbacks
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/client/application.cpp b/client/application.cpp
index 43fe7fa..d9da67f 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -2359,7 +2359,7 @@ bool Application::process_cmd_line(int argc, char** argv, bool &full_screen)
case SPICE_OPT_VERSION: {
std::ostringstream os;
os << argv[0] << " "<< PACKAGE_VERSION << std::endl;
- Platform::term_printf(os.str().c_str());
+ Platform::term_printf("%s", os.str().c_str());
return false;
}
case SPICE_OPT_HOST:
diff --git a/client/client_net_socket.cpp b/client/client_net_socket.cpp
index e9f1e77..9df6801 100644
--- a/client/client_net_socket.cpp
+++ b/client/client_net_socket.cpp
@@ -147,7 +147,7 @@ void ClientNetSocket::push_send(SendBuffer& buf)
}
if (_fin_pending || _close_pending) {
- THROW("%s: unexpected send attempt for connection_id=% - shutdown send pending",
+ THROW("%s: unexpected send attempt for connection_id=%d - shutdown send pending",
__FUNCTION__, _id);
}
diff --git a/client/cmd_line_parser.cpp b/client/cmd_line_parser.cpp
index b937fb0..12d5945 100644
--- a/client/cmd_line_parser.cpp
+++ b/client/cmd_line_parser.cpp
@@ -514,5 +514,5 @@ void CmdLineParser::show_help()
}
os << "\n";
- Platform::term_printf(os.str().c_str());
+ Platform::term_printf("%s", os.str().c_str());
}
diff --git a/client/hot_keys.cpp b/client/hot_keys.cpp
index 2d0b9db..763ba2c 100644
--- a/client/hot_keys.cpp
+++ b/client/hot_keys.cpp
@@ -139,9 +139,7 @@ void HotKeysParser::add_hotkey(const std::string& hotkey, const CommandsMap& com
std::string command_name = hotkey.substr(0, key_start);
if (commands_map.find(command_name) == commands_map.end()) {
- char buf[1000];
- snprintf(buf, sizeof(buf), "invalid action bname %s", command_name.c_str());
- THROW(buf);
+ THROW("invalid action bname %s", command_name.c_str());
}
int command_id = commands_map.find(command_name)->second;
std::string keys = hotkey.substr(key_start + 1);
diff --git a/client/platform.h b/client/platform.h
index 2025ad9..913bcde 100644
--- a/client/platform.h
+++ b/client/platform.h
@@ -42,7 +42,7 @@ public:
static void path_append(std::string& path, const std::string& partial_path);
static uint64_t get_process_id();
static uint64_t get_thread_id();
- static void term_printf(const char* format, ...);
+ static SPICE_GNUC_PRINTF(1, 2) void term_printf(const char* format, ...);
static void error_beep();
static const MonitorsList& init_monitors();
diff --git a/client/red_peer.cpp b/client/red_peer.cpp
index 64e43d5..10640c8 100644
--- a/client/red_peer.cpp
+++ b/client/red_peer.cpp
@@ -38,7 +38,7 @@ static void ssl_error()
unsigned long last_error = ERR_peek_last_error();
ERR_print_errors_fp(stderr);
- THROW_ERR(SPICEC_ERROR_CODE_SSL_ERROR, "SSL Error:", ERR_error_string(last_error, NULL));
+ THROW_ERR(SPICEC_ERROR_CODE_SSL_ERROR, "SSL Error: %s", ERR_error_string(last_error, NULL));
}
RedPeer::RedPeer()
diff --git a/client/utils.h b/client/utils.h
index 8f32008..c23e04f 100644
--- a/client/utils.h
+++ b/client/utils.h
@@ -98,7 +98,7 @@ static inline void set_bit_be(const void* addr, int bit)
int str_to_port(const char *str);
void string_vprintf(std::string& str, const char* format, va_list ap);
-void string_printf(std::string& str, const char *format, ...);
+SPICE_GNUC_PRINTF(2, 3) void string_printf(std::string& str, const char *format, ...);
template<class T>
class FreeObject {
diff --git a/server/glz_encoder_config.h b/server/glz_encoder_config.h
index 157e3a2..886c68b 100644
--- a/server/glz_encoder_config.h
+++ b/server/glz_encoder_config.h
@@ -25,9 +25,9 @@ typedef void GlzUsrImageContext;
typedef struct GlzEncoderUsrContext GlzEncoderUsrContext;
struct GlzEncoderUsrContext {
- void (*error)(GlzEncoderUsrContext *usr, const char *fmt, ...);
- void (*warn)(GlzEncoderUsrContext *usr, const char *fmt, ...);
- void (*info)(GlzEncoderUsrContext *usr, const char *fmt, ...);
+ SPICE_GNUC_PRINTF(2, 3) void (*error)(GlzEncoderUsrContext *usr, const char *fmt, ...);
+ SPICE_GNUC_PRINTF(2, 3) void (*warn)(GlzEncoderUsrContext *usr, const char *fmt, ...);
+ SPICE_GNUC_PRINTF(2, 3) void (*info)(GlzEncoderUsrContext *usr, const char *fmt, ...);
void *(*malloc)(GlzEncoderUsrContext *usr, int size);
void (*free)(GlzEncoderUsrContext *usr, void *ptr);
diff --git a/server/red_worker.c b/server/red_worker.c
index 3bb7d3e..1a0438e 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -5274,7 +5274,7 @@ static int red_display_free_some_independent_glz_drawables(DisplayChannelClient
/******************************************************
* Encoders callbacks
*******************************************************/
-static void quic_usr_error(QuicUsrContext *usr, const char *fmt, ...)
+static SPICE_GNUC_PRINTF(2, 3) void quic_usr_error(QuicUsrContext *usr, const char *fmt, ...)
{
EncoderData *usr_data = &(((QuicData *)usr)->data);
va_list ap;
@@ -5287,7 +5287,7 @@ static void quic_usr_error(QuicUsrContext *usr, const char *fmt, ...)
longjmp(usr_data->jmp_env, 1);
}
-static void lz_usr_error(LzUsrContext *usr, const char *fmt, ...)
+static SPICE_GNUC_PRINTF(2, 3) void lz_usr_error(LzUsrContext *usr, const char *fmt, ...)
{
EncoderData *usr_data = &(((LzData *)usr)->data);
va_list ap;
@@ -5300,7 +5300,7 @@ static void lz_usr_error(LzUsrContext *usr, const char *fmt, ...)
longjmp(usr_data->jmp_env, 1);
}
-static void glz_usr_error(GlzEncoderUsrContext *usr, const char *fmt, ...)
+static SPICE_GNUC_PRINTF(2, 3) void glz_usr_error(GlzEncoderUsrContext *usr, const char *fmt, ...)
{
EncoderData *usr_data = &(((GlzData *)usr)->data);
va_list ap;
@@ -5315,7 +5315,7 @@ static void glz_usr_error(GlzEncoderUsrContext *usr, const char *fmt, ...)
// and the client
}
-static void quic_usr_warn(QuicUsrContext *usr, const char *fmt, ...)
+static SPICE_GNUC_PRINTF(2, 3) void quic_usr_warn(QuicUsrContext *usr, const char *fmt, ...)
{
EncoderData *usr_data = &(((QuicData *)usr)->data);
va_list ap;
@@ -5326,7 +5326,7 @@ static void quic_usr_warn(QuicUsrContext *usr, const char *fmt, ...)
spice_printerr("%s", usr_data->message_buf);
}
-static void lz_usr_warn(LzUsrContext *usr, const char *fmt, ...)
+static SPICE_GNUC_PRINTF(2, 3) void lz_usr_warn(LzUsrContext *usr, const char *fmt, ...)
{
EncoderData *usr_data = &(((LzData *)usr)->data);
va_list ap;
@@ -5337,7 +5337,7 @@ static void lz_usr_warn(LzUsrContext *usr, const char *fmt, ...)
spice_printerr("%s", usr_data->message_buf);
}
-static void glz_usr_warn(GlzEncoderUsrContext *usr, const char *fmt, ...)
+static SPICE_GNUC_PRINTF(2, 3) void glz_usr_warn(GlzEncoderUsrContext *usr, const char *fmt, ...)
{
EncoderData *usr_data = &(((GlzData *)usr)->data);
va_list ap;
commit 832a98800d7ec97796eec3697e00e81f92a07898
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Tue Mar 13 15:16:41 2012 +0000
Fix const-ness violations
* server/red_worker.c: Add missing const for return type
* server/reds.c: Static strings must be declared const
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/server/red_worker.c b/server/red_worker.c
index 07782c8..3bb7d3e 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -1202,7 +1202,7 @@ static inline void validate_surface(RedWorker *worker, uint32_t surface_id)
}
}
-static char *draw_type_to_str(uint8_t type)
+static const char *draw_type_to_str(uint8_t type)
{
switch (type) {
case QXL_DRAW_FILL:
diff --git a/server/reds.c b/server/reds.c
index bf26864..53fc748 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -97,7 +97,7 @@ static int spice_secure_port = -1;
static int spice_listen_socket_fd = -1;
static char spice_addr[256];
static int spice_family = PF_UNSPEC;
-static char *default_renderer = "sw";
+static const char *default_renderer = "sw";
static int sasl_enabled = 0; // sasl disabled by default
#if HAVE_SASL
static char *sasl_appname = NULL; // default to "spice" if NULL
@@ -1730,7 +1730,7 @@ static void reds_channel_do_link(RedChannel *channel, RedClient *client,
spice_assert(stream);
if (link_msg->channel_type == SPICE_CHANNEL_INPUTS && !stream->ssl) {
- char *mess = "keyboard channel is insecure";
+ const char *mess = "keyboard channel is insecure";
const int mess_len = strlen(mess);
main_channel_push_notify(reds->main_channel, (uint8_t*)mess, mess_len);
}
commit e139521928bb1b390aa4a99a69f63ae3484877cc
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Tue Mar 13 15:16:13 2012 +0000
Don't do arithmetic on void * type, use uint8_t instead
Arithmetic on void * types is non-portable & trivially avoided
* server/dispatcher.c: Use uint8_t for arithmetic
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
diff --git a/server/dispatcher.c b/server/dispatcher.c
index cc20f89..298f5f9 100644
--- a/server/dispatcher.c
+++ b/server/dispatcher.c
@@ -49,7 +49,7 @@
* if 0 poll first, return immediately if no bytes available, otherwise
* read size in blocking mode.
*/
-static int read_safe(int fd, void *buf, size_t size, int block)
+static int read_safe(int fd, uint8_t *buf, size_t size, int block)
{
int read_size = 0;
int ret;
@@ -94,7 +94,7 @@ static int read_safe(int fd, void *buf, size_t size, int block)
* write_safe
* @return -1 for error, otherwise number of written bytes. may be zero.
*/
-static int write_safe(int fd, void *buf, size_t size)
+static int write_safe(int fd, uint8_t *buf, size_t size)
{
int written_size = 0;
int ret;
@@ -121,7 +121,7 @@ static int dispatcher_handle_single_read(Dispatcher *dispatcher)
uint8_t *payload = dispatcher->payload;
uint32_t ack = ACK;
- if ((ret = read_safe(dispatcher->recv_fd, &type, sizeof(type), 0)) == -1) {
+ if ((ret = read_safe(dispatcher->recv_fd, (uint8_t*)&type, sizeof(type), 0)) == -1) {
spice_printerr("error reading from dispatcher: %d", errno);
return 0;
}
@@ -142,7 +142,7 @@ static int dispatcher_handle_single_read(Dispatcher *dispatcher)
}
if (msg->ack == DISPATCHER_ACK) {
if (write_safe(dispatcher->recv_fd,
- &ack, sizeof(ack)) == -1) {
+ (uint8_t*)&ack, sizeof(ack)) == -1) {
spice_printerr("error writing ack for message %d", type);
/* TODO: close socketpair? */
}
@@ -174,7 +174,7 @@ void dispatcher_send_message(Dispatcher *dispatcher, uint32_t message_type,
assert(dispatcher->messages[message_type].handler);
msg = &dispatcher->messages[message_type];
pthread_mutex_lock(&dispatcher->lock);
- if (write_safe(send_fd, &message_type, sizeof(message_type)) == -1) {
+ if (write_safe(send_fd, (uint8_t*)&message_type, sizeof(message_type)) == -1) {
spice_printerr("error: failed to send message type for message %d",
message_type);
goto unlock;
@@ -185,7 +185,7 @@ void dispatcher_send_message(Dispatcher *dispatcher, uint32_t message_type,
goto unlock;
}
if (msg->ack == DISPATCHER_ACK) {
- if (read_safe(send_fd, &ack, sizeof(ack), 1) == -1) {
+ if (read_safe(send_fd, (uint8_t*)&ack, sizeof(ack), 1) == -1) {
spice_printerr("error: failed to read ack");
} else if (ack != ACK) {
spice_printerr("error: got wrong ack value in dispatcher "
More information about the Spice-commits
mailing list