Pino Toscano
2019-Apr-23 16:28 UTC
[Libguestfs] [PATCH 0/7] Make deprecation warnings more prominent
Since there are deprecated APIs, make sure that users notice they are deprecated in more prominent ways than done so far: - using deprecated C functions now warns by default - it is possible to use the C library making sure no deprecated function is ever used - Python/Ruby/Perl scripts now get warning messages (configured according to their own systems) when deprecated functions are used The Java binding already emits warnings since libguestfs 1.29.25 (85b6b5e589bea56046b85a5b0143a364e20dacd1). Pino Toscano (7): tests: switch last-errno away from deprecated APIs lib: enable deprecation warnings by default build: stop using GUESTFS_WARN_DEPRECATED lib: introduce GUESTFS_NO_DEPRECATED python: show warnings for deprecated functions ruby: show warnings for deprecated functions perl: show warnings for deprecated functions align/Makefile.am | 2 +- cat/Makefile.am | 10 +++++----- common/edit/Makefile.am | 2 +- common/options/Makefile.am | 2 +- common/parallel/Makefile.am | 2 +- common/progress/Makefile.am | 2 +- common/structs/Makefile.am | 2 +- common/utils/Makefile.am | 2 +- common/visit/Makefile.am | 2 +- common/windows/Makefile.am | 2 +- df/Makefile.am | 2 +- diff/Makefile.am | 2 +- edit/Makefile.am | 2 +- examples/Makefile.am | 17 ++++++++--------- fish/Makefile.am | 2 +- format/Makefile.am | 2 +- fuse/Makefile.am | 3 ++- generator/GObject.ml | 4 ++++ generator/OCaml.ml | 4 ++++ generator/c.ml | 20 +++++++++++++++++--- generator/erlang.ml | 4 ++++ generator/fish.ml | 3 ++- generator/golang.ml | 2 +- generator/java.ml | 4 ++++ generator/lua.ml | 4 ++++ generator/perl.ml | 16 +++++++++++++++- generator/php.ml | 4 ++++ generator/python.ml | 16 ++++++++++++++++ generator/ruby.ml | 14 ++++++++++++++ generator/tests_c_api.ml | 4 ++++ inspector/Makefile.am | 2 +- lib/Makefile.am | 1 - make-fs/Makefile.am | 2 +- rescue/Makefile.am | 2 +- test-tool/Makefile.am | 2 +- tests/c-api/test-last-errno.c | 4 ++-- tests/c-api/tests-main.c | 5 ----- tests/mount-local/Makefile.am | 2 +- tests/mountable/Makefile.am | 2 +- tests/parallel/Makefile.am | 2 +- tests/regressions/Makefile.am | 2 ++ 41 files changed, 133 insertions(+), 50 deletions(-) -- 2.20.1
Pino Toscano
2019-Apr-23 16:28 UTC
[Libguestfs] [PATCH 1/7] tests: switch last-errno away from deprecated APIs
This test only calls stat to check the failure on missing file, so switch to statns to get the same behaviour with a non-deprecated API. --- tests/c-api/test-last-errno.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/c-api/test-last-errno.c b/tests/c-api/test-last-errno.c index 9c5b2cf3a..056acd526 100644 --- a/tests/c-api/test-last-errno.c +++ b/tests/c-api/test-last-errno.c @@ -38,7 +38,7 @@ main (int argc, char *argv[]) { guestfs_h *g; int r, err; - struct guestfs_stat *stat; + struct guestfs_statns *stat; g = guestfs_create (); if (g == NULL) @@ -79,7 +79,7 @@ main (int argc, char *argv[]) if (guestfs_mount (g, "/dev/sda1", "/") == -1) exit (EXIT_FAILURE); - stat = guestfs_lstat (g, "/nosuchfile"); + stat = guestfs_lstatns (g, "/nosuchfile"); if (stat != NULL) error (EXIT_FAILURE, 0, "guestfs_lstat: expected error for missing file"); -- 2.20.1
Pino Toscano
2019-Apr-23 16:28 UTC
[Libguestfs] [PATCH 2/7] 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 --- 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
Pino Toscano
2019-Apr-23 16:28 UTC
[Libguestfs] [PATCH 3/7] build: stop using GUESTFS_WARN_DEPRECATED
This is no more used now, as compiler deprecation warnings are triggered by default. --- align/Makefile.am | 1 - cat/Makefile.am | 5 ----- common/edit/Makefile.am | 1 - common/options/Makefile.am | 1 - common/parallel/Makefile.am | 1 - common/progress/Makefile.am | 1 - common/structs/Makefile.am | 1 - common/utils/Makefile.am | 1 - common/visit/Makefile.am | 1 - common/windows/Makefile.am | 1 - df/Makefile.am | 1 - diff/Makefile.am | 1 - edit/Makefile.am | 1 - examples/Makefile.am | 9 --------- fish/Makefile.am | 1 - format/Makefile.am | 1 - fuse/Makefile.am | 1 - inspector/Makefile.am | 1 - lib/Makefile.am | 1 - make-fs/Makefile.am | 1 - rescue/Makefile.am | 1 - test-tool/Makefile.am | 1 - tests/c-api/tests-main.c | 5 ----- tests/mount-local/Makefile.am | 1 - tests/mountable/Makefile.am | 1 - tests/parallel/Makefile.am | 1 - 26 files changed, 42 deletions(-) diff --git a/align/Makefile.am b/align/Makefile.am index cc8df13f7..6c6fdc455 100644 --- a/align/Makefile.am +++ b/align/Makefile.am @@ -29,7 +29,6 @@ virt_alignment_scan_SOURCES = \ scan.c virt_alignment_scan_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/cat/Makefile.am b/cat/Makefile.am index 9fee8cc1c..b4da82bbe 100644 --- a/cat/Makefile.am +++ b/cat/Makefile.am @@ -36,7 +36,6 @@ virt_cat_SOURCES = \ cat.c virt_cat_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ @@ -64,7 +63,6 @@ virt_filesystems_SOURCES = \ filesystems.c virt_filesystems_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ @@ -92,7 +90,6 @@ virt_log_SOURCES = \ log.c virt_log_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ @@ -119,7 +116,6 @@ virt_ls_SOURCES = \ ls.c virt_ls_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ @@ -148,7 +144,6 @@ virt_tail_SOURCES = \ tail.c virt_tail_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ diff --git a/common/edit/Makefile.am b/common/edit/Makefile.am index d31d57268..8371a6aac 100644 --- a/common/edit/Makefile.am +++ b/common/edit/Makefile.am @@ -25,7 +25,6 @@ libedit_la_SOURCES = \ file-edit.c \ file-edit.h libedit_la_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib libedit_la_CFLAGS = \ diff --git a/common/options/Makefile.am b/common/options/Makefile.am index d7c036fb8..23a13d928 100644 --- a/common/options/Makefile.am +++ b/common/options/Makefile.am @@ -34,7 +34,6 @@ liboptions_la_SOURCES = \ uri.h \ uri.c liboptions_la_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib diff --git a/common/parallel/Makefile.am b/common/parallel/Makefile.am index 6df910037..5254e1723 100644 --- a/common/parallel/Makefile.am +++ b/common/parallel/Makefile.am @@ -30,7 +30,6 @@ libparallel_la_SOURCES = \ parallel.c \ parallel.h libparallel_la_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ -I$(top_srcdir)/common/options -I$(top_builddir)/common/options \ diff --git a/common/progress/Makefile.am b/common/progress/Makefile.am index 794215c6e..acb210327 100644 --- a/common/progress/Makefile.am +++ b/common/progress/Makefile.am @@ -25,7 +25,6 @@ libprogress_la_SOURCES = \ progress.c \ progress.h libprogress_la_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib libprogress_la_CFLAGS = \ diff --git a/common/structs/Makefile.am b/common/structs/Makefile.am index 1762af276..228bcb0f3 100644 --- a/common/structs/Makefile.am +++ b/common/structs/Makefile.am @@ -35,7 +35,6 @@ libstructs_la_SOURCES = \ ../../lib/guestfs.h \ $(BUILT_SOURCES) libstructs_la_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DGUESTFS_PRIVATE=1 \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/lib -I$(top_builddir)/lib diff --git a/common/utils/Makefile.am b/common/utils/Makefile.am index a0154d85f..1849dbb27 100644 --- a/common/utils/Makefile.am +++ b/common/utils/Makefile.am @@ -29,7 +29,6 @@ libutils_la_SOURCES = \ libxml2-writer-macros.h \ utils.c libutils_la_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DGUESTFS_PRIVATE=1 \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/lib -I$(top_builddir)/lib diff --git a/common/visit/Makefile.am b/common/visit/Makefile.am index 8b9136780..62fee334c 100644 --- a/common/visit/Makefile.am +++ b/common/visit/Makefile.am @@ -23,7 +23,6 @@ libvisit_la_SOURCES = \ visit.c \ visit.h libvisit_la_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DGUESTFS_PRIVATE=1 \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/common/windows/Makefile.am b/common/windows/Makefile.am index 23b712b45..14f9ec7f4 100644 --- a/common/windows/Makefile.am +++ b/common/windows/Makefile.am @@ -25,7 +25,6 @@ libwindows_la_SOURCES = \ windows.c \ windows.h libwindows_la_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib diff --git a/df/Makefile.am b/df/Makefile.am index 89ec12a64..bba54500e 100644 --- a/df/Makefile.am +++ b/df/Makefile.am @@ -33,7 +33,6 @@ virt_df_SOURCES = \ output.c virt_df_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ diff --git a/diff/Makefile.am b/diff/Makefile.am index 574981f8b..8db8aca72 100644 --- a/diff/Makefile.am +++ b/diff/Makefile.am @@ -28,7 +28,6 @@ virt_diff_SOURCES = \ diff.c virt_diff_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/edit/Makefile.am b/edit/Makefile.am index 85615719c..fd9887949 100644 --- a/edit/Makefile.am +++ b/edit/Makefile.am @@ -28,7 +28,6 @@ virt_edit_SOURCES = \ edit.c virt_edit_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/examples/Makefile.am b/examples/Makefile.am index c596ce17f..81a8cc0b7 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -43,7 +43,6 @@ endif if HAVE_LIBVIRT copy_over_SOURCES = copy-over.c copy_over_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib copy_over_CFLAGS = \ $(LIBVIRT_CFLAGS) \ @@ -55,7 +54,6 @@ copy_over_LDADD = \ libvirt_auth_SOURCES = libvirt-auth.c libvirt_auth_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib libvirt_auth_CFLAGS = \ $(LIBVIRT_CFLAGS) \ @@ -68,7 +66,6 @@ endif create_disk_SOURCES = create-disk.c create_disk_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib create_disk_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) @@ -77,7 +74,6 @@ create_disk_LDADD = \ debug_logging_SOURCES = debug-logging.c debug_logging_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib debug_logging_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) @@ -86,7 +82,6 @@ debug_logging_LDADD = \ display_icon_SOURCES = display-icon.c display_icon_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib display_icon_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) @@ -95,7 +90,6 @@ display_icon_LDADD = \ inspect_vm_SOURCES = inspect-vm.c inspect_vm_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib inspect_vm_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) @@ -105,10 +99,8 @@ inspect_vm_LDADD = \ if HAVE_FUSE mount_local_SOURCES = mount-local.c mount_local_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib mount_local_CFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ $(FUSE_CFLAGS) \ $(WARN_CFLAGS) $(WERROR_CFLAGS) @@ -120,7 +112,6 @@ endif if HAVE_HIVEX virt_dhcp_address_SOURCES = virt-dhcp-address.c virt_dhcp_address_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib virt_dhcp_address_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) diff --git a/fish/Makefile.am b/fish/Makefile.am index aa8e5add8..001cd0ddf 100644 --- a/fish/Makefile.am +++ b/fish/Makefile.am @@ -123,7 +123,6 @@ cmds-gperf.c: cmds-gperf.gperf mv $@-t $@ guestfish_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ diff --git a/format/Makefile.am b/format/Makefile.am index 2d3cc774c..71876fd90 100644 --- a/format/Makefile.am +++ b/format/Makefile.am @@ -28,7 +28,6 @@ virt_format_SOURCES = \ format.c virt_format_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/fuse/Makefile.am b/fuse/Makefile.am index 57f342dd7..408f77a6a 100644 --- a/fuse/Makefile.am +++ b/fuse/Makefile.am @@ -36,7 +36,6 @@ guestmount_SOURCES = \ guestmount.c guestmount_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/inspector/Makefile.am b/inspector/Makefile.am index 185a9e857..b1604d8c1 100644 --- a/inspector/Makefile.am +++ b/inspector/Makefile.am @@ -49,7 +49,6 @@ virt_inspector_SOURCES = \ inspector.c virt_inspector_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ diff --git a/lib/Makefile.am b/lib/Makefile.am index 742b182cc..95b5edb4e 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -126,7 +126,6 @@ libguestfs_la_SOURCES = \ libguestfs.syms libguestfs_la_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DGUESTFS_PRIVATE=1 \ -I$(top_srcdir)/common/errnostring -I$(top_builddir)/common/errnostring \ -I$(top_srcdir)/common/protocol -I$(top_builddir)/common/protocol \ diff --git a/make-fs/Makefile.am b/make-fs/Makefile.am index 5ba5fb577..6190fa78a 100644 --- a/make-fs/Makefile.am +++ b/make-fs/Makefile.am @@ -28,7 +28,6 @@ virt_make_fs_SOURCES = \ make-fs.c virt_make_fs_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ diff --git a/rescue/Makefile.am b/rescue/Makefile.am index d911484fd..2851ed52e 100644 --- a/rescue/Makefile.am +++ b/rescue/Makefile.am @@ -32,7 +32,6 @@ virt_rescue_SOURCES = \ suggest.c virt_rescue_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DGUESTFS_PRIVATE=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ diff --git a/test-tool/Makefile.am b/test-tool/Makefile.am index 065c8a2fa..36a6c9788 100644 --- a/test-tool/Makefile.am +++ b/test-tool/Makefile.am @@ -33,7 +33,6 @@ libguestfs_test_tool_CPPFLAGS = \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ -I$(top_srcdir)/common/options -I$(top_builddir)/common/options \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" libguestfs_test_tool_CFLAGS = \ diff --git a/tests/c-api/tests-main.c b/tests/c-api/tests-main.c index 14e7798ee..9bfb09f06 100644 --- a/tests/c-api/tests-main.c +++ b/tests/c-api/tests-main.c @@ -31,11 +31,6 @@ #include <pcre.h> -/* Warn about deprecated libguestfs functions, but only in this file, - * not in 'tests.c' (because we want to test deprecated functions). - */ -#define GUESTFS_WARN_DEPRECATED 1 - #include "guestfs.h" #include "guestfs-utils.h" #include "structs-cleanups.h" diff --git a/tests/mount-local/Makefile.am b/tests/mount-local/Makefile.am index 7d90bd022..f36cd81ba 100644 --- a/tests/mount-local/Makefile.am +++ b/tests/mount-local/Makefile.am @@ -29,7 +29,6 @@ check_PROGRAMS = $(TESTS) test_parallel_mount_local_SOURCES = \ test-parallel-mount-local.c test_parallel_mount_local_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/tests/mountable/Makefile.am b/tests/mountable/Makefile.am index c1a1ebf89..058b6856a 100644 --- a/tests/mountable/Makefile.am +++ b/tests/mountable/Makefile.am @@ -27,7 +27,6 @@ check_PROGRAMS = test-internal-parse-mountable test_internal_parse_mountable_SOURCES = test-internal-parse-mountable.c test_internal_parse_mountable_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -DGUESTFS_PRIVATE=1 \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/lib -I$(top_builddir)/lib diff --git a/tests/parallel/Makefile.am b/tests/parallel/Makefile.am index 7f6144089..3ea284ab5 100644 --- a/tests/parallel/Makefile.am +++ b/tests/parallel/Makefile.am @@ -26,7 +26,6 @@ check_PROGRAMS = test-parallel test_parallel_SOURCES = test-parallel.c test_parallel_CPPFLAGS = \ - -DGUESTFS_WARN_DEPRECATED=1 \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib -- 2.20.1
Pino Toscano
2019-Apr-23 16:28 UTC
[Libguestfs] [PATCH 4/7] lib: introduce GUESTFS_NO_DEPRECATED
Add a simple way to do not even provide prototypes of deprecated functions in the C library: this way, users (like our tools) can build against the library making sure to not use any deprecated function, not even when compiler deprecation warnings are disabled. Add it to the majority of our tools/internal libraries, and make sure that it is not defined when building the API bridges of our bindings. --- align/Makefile.am | 1 + cat/Makefile.am | 5 +++++ common/edit/Makefile.am | 1 + common/options/Makefile.am | 1 + common/parallel/Makefile.am | 1 + common/progress/Makefile.am | 1 + common/structs/Makefile.am | 1 + common/utils/Makefile.am | 1 + common/visit/Makefile.am | 1 + common/windows/Makefile.am | 1 + df/Makefile.am | 1 + diff/Makefile.am | 1 + edit/Makefile.am | 1 + examples/Makefile.am | 8 ++++++++ fish/Makefile.am | 1 + format/Makefile.am | 1 + fuse/Makefile.am | 2 ++ generator/GObject.ml | 1 + generator/OCaml.ml | 1 + generator/c.ml | 14 ++++++++++++++ generator/erlang.ml | 1 + generator/fish.ml | 1 + generator/golang.ml | 2 +- generator/java.ml | 1 + generator/lua.ml | 1 + generator/perl.ml | 1 + generator/php.ml | 1 + generator/python.ml | 1 + generator/ruby.ml | 1 + generator/tests_c_api.ml | 1 + inspector/Makefile.am | 1 + make-fs/Makefile.am | 1 + rescue/Makefile.am | 1 + test-tool/Makefile.am | 1 + tests/mount-local/Makefile.am | 1 + tests/mountable/Makefile.am | 1 + tests/parallel/Makefile.am | 1 + 37 files changed, 62 insertions(+), 1 deletion(-) diff --git a/align/Makefile.am b/align/Makefile.am index 6c6fdc455..1c698561b 100644 --- a/align/Makefile.am +++ b/align/Makefile.am @@ -29,6 +29,7 @@ virt_alignment_scan_SOURCES = \ scan.c virt_alignment_scan_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/cat/Makefile.am b/cat/Makefile.am index b4da82bbe..8e731d5b3 100644 --- a/cat/Makefile.am +++ b/cat/Makefile.am @@ -36,6 +36,7 @@ virt_cat_SOURCES = \ cat.c virt_cat_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ @@ -63,6 +64,7 @@ virt_filesystems_SOURCES = \ filesystems.c virt_filesystems_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ @@ -90,6 +92,7 @@ virt_log_SOURCES = \ log.c virt_log_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ @@ -116,6 +119,7 @@ virt_ls_SOURCES = \ ls.c virt_ls_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ @@ -144,6 +148,7 @@ virt_tail_SOURCES = \ tail.c virt_tail_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ diff --git a/common/edit/Makefile.am b/common/edit/Makefile.am index 8371a6aac..45ef9b2d6 100644 --- a/common/edit/Makefile.am +++ b/common/edit/Makefile.am @@ -25,6 +25,7 @@ libedit_la_SOURCES = \ file-edit.c \ file-edit.h libedit_la_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib libedit_la_CFLAGS = \ diff --git a/common/options/Makefile.am b/common/options/Makefile.am index 23a13d928..9b4554dc5 100644 --- a/common/options/Makefile.am +++ b/common/options/Makefile.am @@ -34,6 +34,7 @@ liboptions_la_SOURCES = \ uri.h \ uri.c liboptions_la_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib diff --git a/common/parallel/Makefile.am b/common/parallel/Makefile.am index 5254e1723..bb727e35d 100644 --- a/common/parallel/Makefile.am +++ b/common/parallel/Makefile.am @@ -30,6 +30,7 @@ libparallel_la_SOURCES = \ parallel.c \ parallel.h libparallel_la_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ -I$(top_srcdir)/common/options -I$(top_builddir)/common/options \ diff --git a/common/progress/Makefile.am b/common/progress/Makefile.am index acb210327..6361b413a 100644 --- a/common/progress/Makefile.am +++ b/common/progress/Makefile.am @@ -25,6 +25,7 @@ libprogress_la_SOURCES = \ progress.c \ progress.h libprogress_la_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib libprogress_la_CFLAGS = \ diff --git a/common/structs/Makefile.am b/common/structs/Makefile.am index 228bcb0f3..08fd5c57e 100644 --- a/common/structs/Makefile.am +++ b/common/structs/Makefile.am @@ -35,6 +35,7 @@ libstructs_la_SOURCES = \ ../../lib/guestfs.h \ $(BUILT_SOURCES) libstructs_la_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DGUESTFS_PRIVATE=1 \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/lib -I$(top_builddir)/lib diff --git a/common/utils/Makefile.am b/common/utils/Makefile.am index 1849dbb27..2cd33e506 100644 --- a/common/utils/Makefile.am +++ b/common/utils/Makefile.am @@ -29,6 +29,7 @@ libutils_la_SOURCES = \ libxml2-writer-macros.h \ utils.c libutils_la_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DGUESTFS_PRIVATE=1 \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/lib -I$(top_builddir)/lib diff --git a/common/visit/Makefile.am b/common/visit/Makefile.am index 62fee334c..f45d4fd5e 100644 --- a/common/visit/Makefile.am +++ b/common/visit/Makefile.am @@ -23,6 +23,7 @@ libvisit_la_SOURCES = \ visit.c \ visit.h libvisit_la_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DGUESTFS_PRIVATE=1 \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/common/windows/Makefile.am b/common/windows/Makefile.am index 14f9ec7f4..49e13b616 100644 --- a/common/windows/Makefile.am +++ b/common/windows/Makefile.am @@ -25,6 +25,7 @@ libwindows_la_SOURCES = \ windows.c \ windows.h libwindows_la_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib diff --git a/df/Makefile.am b/df/Makefile.am index bba54500e..92493f123 100644 --- a/df/Makefile.am +++ b/df/Makefile.am @@ -33,6 +33,7 @@ virt_df_SOURCES = \ output.c virt_df_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ diff --git a/diff/Makefile.am b/diff/Makefile.am index 8db8aca72..9452c6de2 100644 --- a/diff/Makefile.am +++ b/diff/Makefile.am @@ -28,6 +28,7 @@ virt_diff_SOURCES = \ diff.c virt_diff_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/edit/Makefile.am b/edit/Makefile.am index fd9887949..5c90a93df 100644 --- a/edit/Makefile.am +++ b/edit/Makefile.am @@ -28,6 +28,7 @@ virt_edit_SOURCES = \ edit.c virt_edit_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/examples/Makefile.am b/examples/Makefile.am index 81a8cc0b7..334da40f0 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -43,6 +43,7 @@ endif if HAVE_LIBVIRT copy_over_SOURCES = copy-over.c copy_over_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib copy_over_CFLAGS = \ $(LIBVIRT_CFLAGS) \ @@ -54,6 +55,7 @@ copy_over_LDADD = \ libvirt_auth_SOURCES = libvirt-auth.c libvirt_auth_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib libvirt_auth_CFLAGS = \ $(LIBVIRT_CFLAGS) \ @@ -66,6 +68,7 @@ endif create_disk_SOURCES = create-disk.c create_disk_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib create_disk_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) @@ -74,6 +77,7 @@ create_disk_LDADD = \ debug_logging_SOURCES = debug-logging.c debug_logging_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib debug_logging_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) @@ -82,6 +86,7 @@ debug_logging_LDADD = \ display_icon_SOURCES = display-icon.c display_icon_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib display_icon_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) @@ -90,6 +95,7 @@ display_icon_LDADD = \ inspect_vm_SOURCES = inspect-vm.c inspect_vm_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib inspect_vm_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) @@ -99,6 +105,7 @@ inspect_vm_LDADD = \ if HAVE_FUSE mount_local_SOURCES = mount-local.c mount_local_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib mount_local_CFLAGS = \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ @@ -112,6 +119,7 @@ endif if HAVE_HIVEX virt_dhcp_address_SOURCES = virt-dhcp-address.c virt_dhcp_address_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/lib -I$(top_builddir)/lib virt_dhcp_address_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) diff --git a/fish/Makefile.am b/fish/Makefile.am index 001cd0ddf..0e01ed9fd 100644 --- a/fish/Makefile.am +++ b/fish/Makefile.am @@ -123,6 +123,7 @@ cmds-gperf.c: cmds-gperf.gperf mv $@-t $@ guestfish_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ diff --git a/format/Makefile.am b/format/Makefile.am index 71876fd90..125c57184 100644 --- a/format/Makefile.am +++ b/format/Makefile.am @@ -28,6 +28,7 @@ virt_format_SOURCES = \ format.c virt_format_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/fuse/Makefile.am b/fuse/Makefile.am index 408f77a6a..e3b4a1cb5 100644 --- a/fuse/Makefile.am +++ b/fuse/Makefile.am @@ -36,6 +36,7 @@ guestmount_SOURCES = \ guestmount.c guestmount_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ @@ -65,6 +66,7 @@ guestunmount_SOURCES = \ guestunmount.c guestunmount_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/generator/GObject.ml b/generator/GObject.ml index 0c8cd232b..4e695a5db 100644 --- a/generator/GObject.ml +++ b/generator/GObject.ml @@ -695,6 +695,7 @@ let generate_gobject_session_source () pr " /* It is safe to call deprecated functions from this file. */ #define GUESTFS_NO_WARN_DEPRECATED +#undef GUESTFS_NO_DEPRECATED #include <glib.h> #include <glib-object.h> diff --git a/generator/OCaml.ml b/generator/OCaml.ml index ad6679629..92a913015 100644 --- a/generator/OCaml.ml +++ b/generator/OCaml.ml @@ -414,6 +414,7 @@ and generate_ocaml_c () /* It is safe to call deprecated functions from this file. */ #define GUESTFS_NO_WARN_DEPRECATED +#undef GUESTFS_NO_DEPRECATED #include <stdio.h> #include <stdlib.h> diff --git a/generator/c.ml b/generator/c.ml index 9d66f5299..d19573a03 100644 --- a/generator/c.ml +++ b/generator/c.ml @@ -559,6 +559,7 @@ typedef void (*guestfs_close_cb) (guestfs_h *g, void *opaque); typedef void (*guestfs_progress_cb) (guestfs_h *g, void *opaque, int proc_nr, int serial, uint64_t position, uint64_t total); #endif +#ifndef GUESTFS_NO_DEPRECATED extern GUESTFS_DLL_PUBLIC void guestfs_set_log_message_callback (guestfs_h *g, guestfs_log_message_cb cb, void *opaque) GUESTFS_DEPRECATED_REPLACED_BY(\"set_event_callback\"); extern GUESTFS_DLL_PUBLIC void guestfs_set_subprocess_quit_callback (guestfs_h *g, guestfs_subprocess_quit_cb cb, void *opaque) @@ -571,6 +572,7 @@ extern GUESTFS_DLL_PUBLIC void guestfs_set_close_callback (guestfs_h *g, guestfs #define GUESTFS_HAVE_SET_PROGRESS_CALLBACK 1 extern GUESTFS_DLL_PUBLIC void guestfs_set_progress_callback (guestfs_h *g, guestfs_progress_cb cb, void *opaque) GUESTFS_DEPRECATED_REPLACED_BY(\"set_event_callback\"); +#endif /* !GUESTFS_NO_DEPRECATED */ /* Private data area. */ #define GUESTFS_HAVE_SET_PRIVATE 1 @@ -657,6 +659,13 @@ extern GUESTFS_DLL_PUBLIC void *guestfs_next_private (guestfs_h *g, const char * ) optargs; ); + let deprecated + match deprecated_by with + | Not_deprecated -> false + | Replaced_by _ | Deprecated_no_replacement -> true in + + if deprecated then + pr "#ifndef GUESTFS_NO_DEPRECATED\n"; generate_prototype ~single_line:true ~semicolon:false ~dll_public:true ~handle:"g" ~prefix:"guestfs_" shortname style; (match deprecated_by with @@ -667,6 +676,8 @@ extern GUESTFS_DLL_PUBLIC void *guestfs_next_private (guestfs_h *g, const char * | Deprecated_no_replacement -> pr "\n GUESTFS_DEPRECATED_NO_REPLACEMENT;\n" ); + if deprecated then + pr "#endif /* !GUESTFS_NO_DEPRECATED */\n"; if optargs <> [] then ( generate_prototype ~single_line:true ~newline:true ~handle:"g" @@ -1332,6 +1343,9 @@ and generate_client_actions actions () pr "\ #include <config.h> +/* It is safe to call deprecated functions from this file. */ +#undef GUESTFS_NO_DEPRECATED + #include <stdio.h> #include <stdlib.h> #include <stdint.h> diff --git a/generator/erlang.ml b/generator/erlang.ml index 11d1f1920..0cee9c3ef 100644 --- a/generator/erlang.ml +++ b/generator/erlang.ml @@ -333,6 +333,7 @@ and generate_erlang_actions actions () /* It is safe to call deprecated functions from this file. */ #define GUESTFS_NO_WARN_DEPRECATED +#undef GUESTFS_NO_DEPRECATED #include <stdio.h> #include <stdlib.h> diff --git a/generator/fish.ml b/generator/fish.ml index d165e2fb0..56489fa44 100644 --- a/generator/fish.ml +++ b/generator/fish.ml @@ -86,6 +86,7 @@ let generate_fish_run_cmds actions () pr "\n"; pr "/* It is safe to call deprecated functions from this file. */\n"; pr "#define GUESTFS_NO_WARN_DEPRECATED\n"; + pr "#undef GUESTFS_NO_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 582b6f808..bd09ae9cf 100644 --- a/generator/golang.ml +++ b/generator/golang.ml @@ -40,7 +40,7 @@ let generate_golang_go () package guestfs /* -#cgo CFLAGS: -DGUESTFS_PRIVATE=1 -DGUESTFS_NO_WARN_DEPRECATED +#cgo CFLAGS: -DGUESTFS_PRIVATE=1 -DGUESTFS_NO_WARN_DEPRECATED -UGUESTFS_NO_DEPRECATED #cgo LDFLAGS: -lguestfs #include <stdio.h> #include <stdlib.h> diff --git a/generator/java.ml b/generator/java.ml index 6849f8a2d..bd92ae0a2 100644 --- a/generator/java.ml +++ b/generator/java.ml @@ -580,6 +580,7 @@ and generate_java_c actions () /* It is safe to call deprecated functions from this file. */ #define GUESTFS_NO_WARN_DEPRECATED +#undef GUESTFS_NO_DEPRECATED #include <stdio.h> #include <stdlib.h> diff --git a/generator/lua.ml b/generator/lua.ml index 8e5d9b7f2..4372e9359 100644 --- a/generator/lua.ml +++ b/generator/lua.ml @@ -41,6 +41,7 @@ let generate_lua_c () /* It is safe to call deprecated functions from this file. */ #define GUESTFS_NO_WARN_DEPRECATED +#undef GUESTFS_NO_DEPRECATED #include <stdio.h> #include <stdlib.h> diff --git a/generator/perl.ml b/generator/perl.ml index 7b89e74e1..efb31077c 100644 --- a/generator/perl.ml +++ b/generator/perl.ml @@ -42,6 +42,7 @@ let rec generate_perl_xs () /* It is safe to call deprecated functions from this file. */ #define GUESTFS_NO_WARN_DEPRECATED +#undef GUESTFS_NO_DEPRECATED #include <stdio.h> #include <stdlib.h> diff --git a/generator/php.ml b/generator/php.ml index 767d48175..b66cfcae2 100644 --- a/generator/php.ml +++ b/generator/php.ml @@ -85,6 +85,7 @@ and generate_php_c () /* It is safe to call deprecated functions from this file. */ #define GUESTFS_NO_WARN_DEPRECATED +#undef GUESTFS_NO_DEPRECATED #include <stdio.h> #include <stdlib.h> diff --git a/generator/python.ml b/generator/python.ml index c67241f5a..7f409b7cd 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -282,6 +282,7 @@ and generate_python_actions actions () /* It is safe to call deprecated functions from this file. */ #define GUESTFS_NO_WARN_DEPRECATED +#undef GUESTFS_NO_DEPRECATED #include <stdio.h> #include <stdlib.h> diff --git a/generator/ruby.ml b/generator/ruby.ml index 77283c298..76fcb58eb 100644 --- a/generator/ruby.ml +++ b/generator/ruby.ml @@ -113,6 +113,7 @@ and generate_ruby_c actions () /* It is safe to call deprecated functions from this file. */ #define GUESTFS_NO_WARN_DEPRECATED +#undef GUESTFS_NO_DEPRECATED #include <stdio.h> #include <stdlib.h> diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml index dd11fd2ae..a4712295a 100644 --- a/generator/tests_c_api.ml +++ b/generator/tests_c_api.ml @@ -40,6 +40,7 @@ let rec generate_c_api_tests () /* It is safe to call deprecated functions from this file. */ #define GUESTFS_NO_WARN_DEPRECATED +#undef GUESTFS_NO_DEPRECATED #include <stdio.h> #include <stdlib.h> diff --git a/inspector/Makefile.am b/inspector/Makefile.am index b1604d8c1..b6dc79027 100644 --- a/inspector/Makefile.am +++ b/inspector/Makefile.am @@ -49,6 +49,7 @@ virt_inspector_SOURCES = \ inspector.c virt_inspector_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ diff --git a/make-fs/Makefile.am b/make-fs/Makefile.am index 6190fa78a..3bba3953e 100644 --- a/make-fs/Makefile.am +++ b/make-fs/Makefile.am @@ -28,6 +28,7 @@ virt_make_fs_SOURCES = \ make-fs.c virt_make_fs_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \ diff --git a/rescue/Makefile.am b/rescue/Makefile.am index 2851ed52e..8ceb57fb4 100644 --- a/rescue/Makefile.am +++ b/rescue/Makefile.am @@ -32,6 +32,7 @@ virt_rescue_SOURCES = \ suggest.c virt_rescue_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DGUESTFS_PRIVATE=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ diff --git a/test-tool/Makefile.am b/test-tool/Makefile.am index 36a6c9788..2daec12ed 100644 --- a/test-tool/Makefile.am +++ b/test-tool/Makefile.am @@ -33,6 +33,7 @@ libguestfs_test_tool_CPPFLAGS = \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ -I$(top_srcdir)/common/options -I$(top_builddir)/common/options \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ + -DGUESTFS_NO_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" libguestfs_test_tool_CFLAGS = \ diff --git a/tests/mount-local/Makefile.am b/tests/mount-local/Makefile.am index f36cd81ba..6231048ff 100644 --- a/tests/mount-local/Makefile.am +++ b/tests/mount-local/Makefile.am @@ -29,6 +29,7 @@ check_PROGRAMS = $(TESTS) test_parallel_mount_local_SOURCES = \ test-parallel-mount-local.c test_parallel_mount_local_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib \ diff --git a/tests/mountable/Makefile.am b/tests/mountable/Makefile.am index 058b6856a..efed5c53f 100644 --- a/tests/mountable/Makefile.am +++ b/tests/mountable/Makefile.am @@ -27,6 +27,7 @@ check_PROGRAMS = test-internal-parse-mountable test_internal_parse_mountable_SOURCES = test-internal-parse-mountable.c test_internal_parse_mountable_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -DGUESTFS_PRIVATE=1 \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/lib -I$(top_builddir)/lib diff --git a/tests/parallel/Makefile.am b/tests/parallel/Makefile.am index 3ea284ab5..5e7b56336 100644 --- a/tests/parallel/Makefile.am +++ b/tests/parallel/Makefile.am @@ -26,6 +26,7 @@ check_PROGRAMS = test-parallel test_parallel_SOURCES = test-parallel.c test_parallel_CPPFLAGS = \ + -DGUESTFS_NO_DEPRECATED=1 \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ -I$(top_srcdir)/lib -I$(top_builddir)/lib -- 2.20.1
Pino Toscano
2019-Apr-23 16:28 UTC
[Libguestfs] [PATCH 5/7] python: show warnings for deprecated functions
Emit a DeprecationWarning warning when a deprecated function is used, so users have a way to know that they are using one. --- generator/python.ml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/generator/python.ml b/generator/python.ml index 7f409b7cd..74acf5de8 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -910,6 +910,18 @@ class GuestFS(object): pr " %s = %s.c_pointer()\n" n n ) args; pr " self._check_not_closed()\n"; + (match f.deprecated_by with + | Not_deprecated -> () + | Replaced_by alt -> + pr " import warnings\n"; + pr " warnings.warn(\"use GuestFS.%s() \"\n" alt; + pr " \"instead of GuestFS.%s()\",\n" f.name; + pr " DeprecationWarning, stacklevel=2)\n"; + | Deprecated_no_replacement -> + pr " import warnings\n"; + pr " warnings.warn(\"do not use GuestFS.%s()\",\n" f.name; + pr " DeprecationWarning, stacklevel=2)\n"; + ); let function_string "self._o" ^ map_join (fun arg -> sprintf ", %s" (name_of_argt arg)) -- 2.20.1
Pino Toscano
2019-Apr-23 16:28 UTC
[Libguestfs] [PATCH 6/7] ruby: show warnings for deprecated functions
Emit a warning when a deprecated function is used, so users have a way to know that they are using one. --- generator/ruby.ml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/generator/ruby.ml b/generator/ruby.ml index 76fcb58eb..ea129fcba 100644 --- a/generator/ruby.ml +++ b/generator/ruby.ml @@ -253,6 +253,16 @@ and generate_ruby_c actions () pr "\n" ); + (match f.deprecated_by with + | Not_deprecated -> () + | Replaced_by alt -> + pr " rb_warn (\"Guestfs#%s is deprecated; use #%s instead\");\n" f.name alt; + pr "\n" + | Deprecated_no_replacement -> + pr " rb_warn (\"Guestfs#%s is deprecated\");\n" f.name; + pr "\n" + ); + List.iter ( function | String (_, n) -> -- 2.20.1
Pino Toscano
2019-Apr-23 16:28 UTC
[Libguestfs] [PATCH 7/7] perl: show warnings for deprecated functions
Emit a deprecation warning when a deprecated function is used, so users have a way to know that they are using one. --- generator/perl.ml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/generator/perl.ml b/generator/perl.ml index efb31077c..af19650a8 100644 --- a/generator/perl.ml +++ b/generator/perl.ml @@ -335,7 +335,7 @@ PREINIT: List.iter ( fun { name; style = (ret, args, optargs as style); - c_function; c_optarg_prefix } -> + c_function; c_optarg_prefix; deprecated_by } -> (match ret with | RErr -> pr "void\n" | RInt _ -> pr "SV *\n" @@ -444,6 +444,16 @@ PREINIT: pr " PPCODE:\n"; ); + (match deprecated_by with + | Not_deprecated -> () + | Replaced_by alt -> + pr " Perl_ck_warner (aTHX_ packWARN(WARN_DEPRECATED),\n"; + pr " \"Sys::Guestfs::%s is deprecated; use Sys::Guestfs::%s instead\");\n" name alt; + | Deprecated_no_replacement -> + pr " Perl_ck_warner (aTHX_ packWARN(WARN_DEPRECATED),\n"; + pr " \"Sys::Guestfs::%s is deprecated\");\n" name; + ); + (* For optional arguments, convert these from the XSUB "items" * variable by hand. *) -- 2.20.1
Richard W.M. Jones
2019-Apr-24 07:40 UTC
Re: [Libguestfs] [PATCH 7/7] perl: show warnings for deprecated functions
Yes this series is fine, ACK. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Seemingly Similar Threads
- [PATCH 0/5] Rename src/ to lib/ and move common code to common/
- [PATCH] Reduce GUESTFS_PRIVATE usage
- [PATCH v2 0/7] Rename src/ to lib/ and move common code to common/
- [PATCH 00/12] Refactor utility functions.
- [PATCH v5 00/32] Refactor utilities, implement some APIs in OCaml.