]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: properly mark two definitions that are deprecated with GCC attributes for...
authorLennart Poettering <lennart@poettering.net>
Tue, 26 Nov 2019 10:23:52 +0000 (11:23 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 31 Jan 2020 14:02:00 +0000 (15:02 +0100)
src/journal-remote/journal-upload.c
src/journal/sd-journal.c
src/systemd/_sd-common.h
src/systemd/sd-journal.h
src/test/generate-sym-test.py

index cc968252887104cf185a969d7b0b5da1325c4815..031e82587d9005a58435f8c88f3053b035bc5f62 100644 (file)
@@ -754,9 +754,13 @@ static int open_journal(sd_journal **j) {
                 r = sd_journal_open_directory(j, arg_directory, arg_journal_type);
         else if (arg_file)
                 r = sd_journal_open_files(j, (const char**) arg_file, 0);
-        else if (arg_machine)
+        else if (arg_machine) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+                /* FIXME: replace with D-Bus call OpenMachineRootDirectory() so that things also work with raw disk images */
                 r = sd_journal_open_container(j, arg_machine, 0);
-        else
+#pragma GCC diagnostic pop
+        } else
                 r = sd_journal_open(j, !arg_merge*SD_JOURNAL_LOCAL_ONLY + arg_journal_type);
         if (r < 0)
                 log_error_errno(r, "Failed to open %s: %m",
index 837aecdf605698bc45392761806cd1e69c8cc1a8..093eb6619e09a8e3cc59093775f5cf5c0687788d 100644 (file)
@@ -1875,7 +1875,7 @@ _public_ int sd_journal_open_container(sd_journal **ret, const char *machine, in
         char *p;
         int r;
 
-        /* This is pretty much deprecated, people should use machined's OpenMachineRootDirectory() call instead in
+        /* This is deprecated, people should use machined's OpenMachineRootDirectory() call instead in
          * combination with sd_journal_open_directory_fd(). */
 
         assert_return(machine, -EINVAL);
index b3ee7bbc24e371a91fd2f530279c83678bdbc778..8158ee733e22e57f9e7c7e6508fbeda129346fa8 100644 (file)
@@ -45,6 +45,18 @@ typedef void (*_sd_destroy_t)(void *userdata);
 #  define _sd_pure_ __attribute__((__pure__))
 #endif
 
+/* Note that strictly speaking __deprecated__ has been available before GCC 6. However, starting with GCC 6
+ * it also works on enum values, which we are interested in. Since this is a developer-facing feature anyway
+ * (as opposed to build engineer-facing), let's hence conditionalize this to gcc 6, given that the developers
+ * are probably going to use something newer anyway. */
+#ifndef _sd_deprecated_
+#  if __GNUC__ >= 6
+#    define _sd_deprecated_ __attribute__((__deprecated__))
+#  else
+#    define _sd_deprecated_
+#  endif
+#endif
+
 #ifndef _SD_STRINGIFY
 #  define _SD_XSTRINGIFY(x) #x
 #  define _SD_STRINGIFY(x) _SD_XSTRINGIFY(x)
index b4bf3b91762f8d316db6d2dbd0396077e43e3c04..dbca4ebce221e3ea9b78316e8735b80ea7e21721 100644 (file)
@@ -70,7 +70,7 @@ enum {
         SD_JOURNAL_CURRENT_USER = 1 << 3,
         SD_JOURNAL_OS_ROOT      = 1 << 4,
 
-        SD_JOURNAL_SYSTEM_ONLY = SD_JOURNAL_SYSTEM /* deprecated name */
+        SD_JOURNAL_SYSTEM_ONLY _sd_deprecated_ = SD_JOURNAL_SYSTEM /* deprecated name */
 };
 
 /* Wakeup event types */
@@ -85,7 +85,7 @@ int sd_journal_open_directory(sd_journal **ret, const char *path, int flags);
 int sd_journal_open_directory_fd(sd_journal **ret, int fd, int flags);
 int sd_journal_open_files(sd_journal **ret, const char **paths, int flags);
 int sd_journal_open_files_fd(sd_journal **ret, int fds[], unsigned n_fds, int flags);
-int sd_journal_open_container(sd_journal **ret, const char *machine, int flags); /* deprecated */
+int sd_journal_open_container(sd_journal **ret, const char *machine, int flags) _sd_deprecated_; /* deprecated */
 void sd_journal_close(sd_journal *j);
 
 int sd_journal_previous(sd_journal *j);
index 4d358b8e345f63c80a5cc9c75d5d327bd9a50c93..fdb9e3ecb789600f66ed77c10ddb08058e53010b 100755 (executable)
@@ -6,6 +6,9 @@ for header in sys.argv[2:]:
     print('#include "{}"'.format(header.split('/')[-1]))
 
 print('''
+/* We want to check deprecated symbols too, without complaining */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
 const void* symbols[] = {''')
 
 for line in open(sys.argv[1]):