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
---
generator/GObject.ml | 3 +++
generator/OCaml.ml | 3 +++
generator/c.ml | 6 +++---
generator/erlang.ml | 3 +++
generator/fish.ml | 2 +-
generator/golang.ml | 2 +-
generator/java.ml | 3 +++
generator/lua.ml | 3 +++
generator/perl.ml | 3 +++
generator/php.ml | 3 +++
generator/python.ml | 3 +++
generator/ruby.ml | 3 +++
generator/tests_c_api.ml | 3 +++
tests/regressions/Makefile.am | 2 ++
14 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/generator/GObject.ml b/generator/GObject.ml
index 7572fb7cc..0c8cd232b 100644
--- a/generator/GObject.ml
+++ b/generator/GObject.ml
@@ -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>
diff --git a/generator/OCaml.ml b/generator/OCaml.ml
index bd4f73b85..ad6679629 100644
--- a/generator/OCaml.ml
+++ b/generator/OCaml.ml
@@ -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>
diff --git a/generator/c.ml b/generator/c.ml
index 86f7d89a3..9d66f5299 100644
--- a/generator/c.ml
+++ b/generator/c.ml
@@ -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\")))
diff --git a/generator/erlang.ml b/generator/erlang.ml
index 8e70cfbd4..11d1f1920 100644
--- a/generator/erlang.ml
+++ b/generator/erlang.ml
@@ -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>
diff --git a/generator/fish.ml b/generator/fish.ml
index a0df28e9e..d165e2fb0 100644
--- a/generator/fish.ml
+++ b/generator/fish.ml
@@ -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";
diff --git a/generator/golang.ml b/generator/golang.ml
index e2cee51d8..582b6f808 100644
--- a/generator/golang.ml
+++ b/generator/golang.ml
@@ -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>
diff --git a/generator/java.ml b/generator/java.ml
index 215b92f0d..6849f8a2d 100644
--- a/generator/java.ml
+++ b/generator/java.ml
@@ -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>
diff --git a/generator/lua.ml b/generator/lua.ml
index bd1ed0a36..8e5d9b7f2 100644
--- a/generator/lua.ml
+++ b/generator/lua.ml
@@ -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>
diff --git a/generator/perl.ml b/generator/perl.ml
index 795834901..7b89e74e1 100644
--- a/generator/perl.ml
+++ b/generator/perl.ml
@@ -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>
diff --git a/generator/php.ml b/generator/php.ml
index e07813f68..767d48175 100644
--- a/generator/php.ml
+++ b/generator/php.ml
@@ -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>
diff --git a/generator/python.ml b/generator/python.ml
index bc5af528c..c67241f5a 100644
--- a/generator/python.ml
+++ b/generator/python.ml
@@ -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>
diff --git a/generator/ruby.ml b/generator/ruby.ml
index 4a090a2b9..77283c298 100644
--- a/generator/ruby.ml
+++ b/generator/ruby.ml
@@ -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>
diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml
index 8f3734b0d..dd11fd2ae 100644
--- a/generator/tests_c_api.ml
+++ b/generator/tests_c_api.ml
@@ -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>
diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am
index fbd5c0ed7..89ee230ba 100644
--- a/tests/regressions/Makefile.am
+++ b/tests/regressions/Makefile.am
@@ -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 = \
--
2.20.1