mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
lib: enable deprecation warnings by default
Right now, deprecated functions of the library do not trigger any compiler deprecation warning by default; they do that only if GUESTFS_WARN_DEPRECATED=1 is defined. However, this is not something that seems to be done often -- at least none of the projects using the libguestfs C API does that. Hence, do a small behaviour change to change this on the other way round: now deprecated functions trigger compiler deprecation warnings by default, using GUESTFS_NO_WARN_DEPRECATED to disable this (and revert to the previous behaviour). Even though deprecated functions will not be removed, we really want users to migrate away from them, as they were deprecated for good reasons. Define GUESTFS_NO_WARN_DEPRECATED where needed: - in all the bindings, as they bind all the functions including the deprecated ones - in the guestfish actions, as it exposes almost all the APIs - in the C API test, as it runs the automated tests of all the APIs that have them - for two tests that explicitly test deprecated functions
This commit is contained in:
@@ -693,6 +693,9 @@ let generate_gobject_session_source () =
|
||||
source_start ~shortdesc filename;
|
||||
|
||||
pr "
|
||||
/* It is safe to call deprecated functions from this file. */
|
||||
#define GUESTFS_NO_WARN_DEPRECATED
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <guestfs.h>
|
||||
|
||||
@@ -412,6 +412,9 @@ and generate_ocaml_c () =
|
||||
pr "\
|
||||
#include <config.h>
|
||||
|
||||
/* It is safe to call deprecated functions from this file. */
|
||||
#define GUESTFS_NO_WARN_DEPRECATED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -439,17 +439,17 @@ extern \"C\" {
|
||||
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
||||
#endif
|
||||
|
||||
/* Define GUESTFS_WARN_DEPRECATED=1 to warn about deprecated API functions. */
|
||||
/* Define GUESTFS_NO_WARN_DEPRECATED to not warn about deprecated API functions. */
|
||||
#define GUESTFS_DEPRECATED_NO_REPLACEMENT
|
||||
#define GUESTFS_DEPRECATED_REPLACED_BY(s)
|
||||
#if GUESTFS_WARN_DEPRECATED
|
||||
#ifndef GUESTFS_NO_WARN_DEPRECATED
|
||||
# if defined(__GNUC__) && GUESTFS_GCC_VERSION >= 40500 /* gcc >= 4.5 */
|
||||
# undef GUESTFS_DEPRECATED_NO_REPLACEMENT
|
||||
# undef GUESTFS_DEPRECATED_REPLACED_BY
|
||||
# define GUESTFS_DEPRECATED_NO_REPLACEMENT __attribute__((__deprecated__))
|
||||
# define GUESTFS_DEPRECATED_REPLACED_BY(s) __attribute__((__deprecated__(\"change the program to use guestfs_\" s \" instead of this deprecated function\")))
|
||||
# endif
|
||||
#endif /* GUESTFS_WARN_DEPRECATED */
|
||||
#endif /* !GUESTFS_NO_WARN_DEPRECATED */
|
||||
|
||||
#if defined(__GNUC__) && GUESTFS_GCC_VERSION >= 40000 /* gcc >= 4.0 */
|
||||
# define GUESTFS_DLL_PUBLIC __attribute__((visibility (\"default\")))
|
||||
|
||||
@@ -331,6 +331,9 @@ and generate_erlang_actions actions () =
|
||||
pr "\
|
||||
#include <config.h>
|
||||
|
||||
/* It is safe to call deprecated functions from this file. */
|
||||
#define GUESTFS_NO_WARN_DEPRECATED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -85,7 +85,7 @@ let generate_fish_run_cmds actions () =
|
||||
pr "#include <config.h>\n";
|
||||
pr "\n";
|
||||
pr "/* It is safe to call deprecated functions from this file. */\n";
|
||||
pr "#undef GUESTFS_WARN_DEPRECATED\n";
|
||||
pr "#define GUESTFS_NO_WARN_DEPRECATED\n";
|
||||
pr "\n";
|
||||
pr "#include <stdio.h>\n";
|
||||
pr "#include <stdlib.h>\n";
|
||||
|
||||
@@ -40,7 +40,7 @@ let generate_golang_go () =
|
||||
package guestfs
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -DGUESTFS_PRIVATE=1
|
||||
#cgo CFLAGS: -DGUESTFS_PRIVATE=1 -DGUESTFS_NO_WARN_DEPRECATED
|
||||
#cgo LDFLAGS: -lguestfs
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -578,6 +578,9 @@ and generate_java_c actions () =
|
||||
pr "\
|
||||
#include <config.h>
|
||||
|
||||
/* It is safe to call deprecated functions from this file. */
|
||||
#define GUESTFS_NO_WARN_DEPRECATED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -39,6 +39,9 @@ let generate_lua_c () =
|
||||
pr "\
|
||||
#include <config.h>
|
||||
|
||||
/* It is safe to call deprecated functions from this file. */
|
||||
#define GUESTFS_NO_WARN_DEPRECATED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -40,6 +40,9 @@ let rec generate_perl_xs () =
|
||||
pr "\
|
||||
#include <config.h>
|
||||
|
||||
/* It is safe to call deprecated functions from this file. */
|
||||
#define GUESTFS_NO_WARN_DEPRECATED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -83,6 +83,9 @@ and generate_php_c () =
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* It is safe to call deprecated functions from this file. */
|
||||
#define GUESTFS_NO_WARN_DEPRECATED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
@@ -280,6 +280,9 @@ and generate_python_actions actions () =
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* It is safe to call deprecated functions from this file. */
|
||||
#define GUESTFS_NO_WARN_DEPRECATED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -111,6 +111,9 @@ and generate_ruby_c actions () =
|
||||
pr "\
|
||||
#include <config.h>
|
||||
|
||||
/* It is safe to call deprecated functions from this file. */
|
||||
#define GUESTFS_NO_WARN_DEPRECATED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -38,6 +38,9 @@ let rec generate_c_api_tests () =
|
||||
pr "\
|
||||
#include <config.h>
|
||||
|
||||
/* It is safe to call deprecated functions from this file. */
|
||||
#define GUESTFS_NO_WARN_DEPRECATED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -106,6 +106,7 @@ check_PROGRAMS = \
|
||||
|
||||
rhbz501893_SOURCES = rhbz501893.c
|
||||
rhbz501893_CPPFLAGS = \
|
||||
-DGUESTFS_NO_WARN_DEPRECATED=1 \
|
||||
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
|
||||
-I$(top_srcdir)/lib -I$(top_builddir)/lib
|
||||
rhbz501893_CFLAGS = \
|
||||
@@ -144,6 +145,7 @@ rhbz914931_LDADD = \
|
||||
|
||||
rhbz1055452_SOURCES = rhbz1055452.c
|
||||
rhbz1055452_CPPFLAGS = \
|
||||
-DGUESTFS_NO_WARN_DEPRECATED=1 \
|
||||
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
|
||||
-I$(top_srcdir)/lib -I$(top_builddir)/lib
|
||||
rhbz1055452_CFLAGS = \
|
||||
|
||||
Reference in New Issue
Block a user