]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
blob: Get rid of the two dummy event handlers.
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 23 Mar 2025 20:53:15 +0000 (21:53 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 3 May 2025 16:45:49 +0000 (18:45 +0200)
The four blob operation structures defined in blob.c are created by
a macro which initializes the function pointer for the event handler
to ${name}_event_handler, where $name is the blob type, i.e. one of
images, lyrics, moods, playlists.

Only two of the four, moods and playlists, need an event handler
because the images and lyrics tables ignore events. Currently we
have to define dummy functions {images,lyrics}_event_handler() to
avoid link errors. This extra code can easily be avoided by making
the macros a little smarter.

afs.c
blob.c

diff --git a/afs.c b/afs.c
index 286f6df656a2ac615331b36289785a8f09ab833e..f96d9c9104e12f317799e5c09fbbeef7781c8e78 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -1165,35 +1165,3 @@ __must_check int afs_event(enum afs_events event, struct para_buffer *pb,
        }
        return 1;
 }
-
-/**
- * Dummy event handler for the images table.
- *
- * \param event Unused.
- * \param pb Unused.
- * \param data Unused.
- *
- * \return The images table does not honor events, so this handler always
- * returns success.
- */
-__a_const int images_event_handler(__a_unused enum afs_events event,
-       __a_unused  struct para_buffer *pb, __a_unused void *data)
-{
-       return 1;
-}
-
-/**
- * Dummy event handler for the lyrics table.
- *
- * \param event Unused.
- * \param pb Unused.
- * \param data Unused.
- *
- * \return The lyrics table does not honor events, so this handler always
- * returns success.
- */
-__a_const int lyrics_event_handler(__a_unused enum afs_events event,
-       __a_unused struct para_buffer *pb, __a_unused void *data)
-{
-       return 1;
-}
diff --git a/blob.c b/blob.c
index 1802de5d31f89bf6fe951c5977cbef4967f9c11e..1b969484bb6f92509673dcd07edb18360e30adfc 100644 (file)
--- a/blob.c
+++ b/blob.c
@@ -625,20 +625,20 @@ static int blob_open(struct osl_table **table,
        }
 
 /** Blob tables map integers to blobs. */
-#define DEFINE_BLOB_AFS_TABLE_OPS(table_name) \
+#define DEFINE_BLOB_AFS_TABLE_OPS(table_name, ehandler) \
        const struct afs_table_operations table_name ## _ops = { \
                .open = table_name ## _open, \
                .close = table_name ## _close, \
                .create = table_name ## _create, \
-               .event_handler = table_name ##_event_handler, \
+               .event_handler = ehandler, \
        };
 
 /** Define all functions for this blob type. */
-#define DEFINE_BLOB_FUNCTIONS(table_name, short_name, c_short_name) \
+#define DEFINE_BLOB_FUNCTIONS(table_name, short_name, c_short_name, ehandler) \
        DEFINE_BLOB_OPEN(table_name) \
        DEFINE_BLOB_CLOSE(table_name) \
        DEFINE_BLOB_CREATE(table_name) \
-       DEFINE_BLOB_AFS_TABLE_OPS(table_name) \
+       DEFINE_BLOB_AFS_TABLE_OPS(table_name, ehandler) \
        DEFINE_BLOB_COMMAND(ls, LS, table_name, short_name, c_short_name) \
        DEFINE_BLOB_COMMAND(cat, CAT, table_name, short_name, c_short_name) \
        DEFINE_BLOB_COMMAND(add, ADD, table_name, short_name, c_short_name) \
@@ -651,8 +651,8 @@ static int blob_open(struct osl_table **table,
 
 /* doxygen isn't smart enough to recognize these */
 /** \cond blob_function */
-DEFINE_BLOB_FUNCTIONS(lyrics, lyr, LYR);
-DEFINE_BLOB_FUNCTIONS(images, img, IMG);
-DEFINE_BLOB_FUNCTIONS(moods, mood, MOOD);
-DEFINE_BLOB_FUNCTIONS(playlists, pl, PL);
+DEFINE_BLOB_FUNCTIONS(lyrics, lyr, LYR, NULL);
+DEFINE_BLOB_FUNCTIONS(images, img, IMG, NULL);
+DEFINE_BLOB_FUNCTIONS(moods, mood, MOOD, moods_event_handler);
+DEFINE_BLOB_FUNCTIONS(playlists, pl, PL, playlists_event_handler);
 /** \endcond blob_function */