From: Andre Noll Date: Sun, 23 Mar 2025 20:53:15 +0000 (+0100) Subject: blob: Get rid of the two dummy event handlers. X-Git-Url: https://git.tuebingen.mpg.de/?a=commitdiff_plain;h=06090f39723cc71626a8625bc8eb4e2750ecb27b;p=paraslash.git blob: Get rid of the two dummy event handlers. 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. --- diff --git a/afs.c b/afs.c index 286f6df6..f96d9c91 100644 --- 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 1802de5d..1b969484 100644 --- 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 */