index: explicitly follow GObject conventions

Use explicit labels for GTypeInfo member initializers, rather than
relying on comments and ordering.  This is both easier to read, and
harder to screw up.  This also makes it clear that we're mis-casting
GObject class initializers for gcc.

Without this patch, g++ 8.2.0-7 produces this warning:

CXX  -g -O2 lib/index.o
lib/index.cc: In function ‘GMimeFilter* notmuch_filter_discard_non_term_new(GMimeContentType*)’:
lib/index.cc:252:23: warning: cast between incompatible function types from ‘void (*)(NotmuchFilterDiscardNonTermClass*)’ {aka ‘void (*)(_NotmuchFilterDiscardNonTermClass*)’} to ‘GClassInitFunc’ {aka ‘void (*)(void*, void*)’} [-Wcast-function-type]
      (GClassInitFunc) notmuch_filter_discard_non_term_class_init,
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The definition of GClassInitFunc in
/usr/include/glib-2.0/gobject/gtype.h suggests that this function will
always be called with the class_data member of the GTypeInfo.  We set
that value to NULL in both GObject definitions in notmuch. So we mark
it as explicitly unused.

There is no functional change here, just code cleanup.
This commit is contained in:
Daniel Kahn Gillmor 2018-10-06 21:37:57 -04:00 committed by David Bremner
parent 64bfe544fd
commit f5411574af
2 changed files with 25 additions and 23 deletions

View file

@ -19,6 +19,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "gmime-filter-reply.h" #include "gmime-filter-reply.h"
#include "notmuch-client.h"
/** /**
* SECTION: gmime-filter-reply * SECTION: gmime-filter-reply
@ -29,7 +30,7 @@
**/ **/
static void g_mime_filter_reply_class_init (GMimeFilterReplyClass *klass); static void g_mime_filter_reply_class_init (GMimeFilterReplyClass *klass, void *class_data);
static void g_mime_filter_reply_init (GMimeFilterReply *filter, GMimeFilterReplyClass *klass); static void g_mime_filter_reply_init (GMimeFilterReply *filter, GMimeFilterReplyClass *klass);
static void g_mime_filter_reply_finalize (GObject *object); static void g_mime_filter_reply_finalize (GObject *object);
@ -50,16 +51,16 @@ g_mime_filter_reply_get_type (void)
if (!type) { if (!type) {
static const GTypeInfo info = { static const GTypeInfo info = {
sizeof (GMimeFilterReplyClass), .class_size = sizeof (GMimeFilterReplyClass),
NULL, /* base_class_init */ .base_init = NULL,
NULL, /* base_class_finalize */ .base_finalize = NULL,
(GClassInitFunc) g_mime_filter_reply_class_init, .class_init = (GClassInitFunc) g_mime_filter_reply_class_init,
NULL, /* class_finalize */ .class_finalize = NULL,
NULL, /* class_data */ .class_data = NULL,
sizeof (GMimeFilterReply), .instance_size = sizeof (GMimeFilterReply),
0, /* n_preallocs */ .n_preallocs = 0,
(GInstanceInitFunc) g_mime_filter_reply_init, .instance_init = (GInstanceInitFunc) g_mime_filter_reply_init,
NULL /* value_table */ .value_table = NULL,
}; };
type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterReply", &info, (GTypeFlags) 0); type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterReply", &info, (GTypeFlags) 0);
@ -70,7 +71,7 @@ g_mime_filter_reply_get_type (void)
static void static void
g_mime_filter_reply_class_init (GMimeFilterReplyClass *klass) g_mime_filter_reply_class_init (GMimeFilterReplyClass *klass, unused (void *class_data))
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass); GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass);

View file

@ -142,7 +142,8 @@ static void filter_reset (GMimeFilter *filter);
static GMimeFilterClass *parent_class = NULL; static GMimeFilterClass *parent_class = NULL;
static void static void
notmuch_filter_discard_non_term_class_init (NotmuchFilterDiscardNonTermClass *klass) notmuch_filter_discard_non_term_class_init (NotmuchFilterDiscardNonTermClass *klass,
unused (void *class_data))
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass); GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass);
@ -246,16 +247,16 @@ notmuch_filter_discard_non_term_new (GMimeContentType *content_type)
if (!type) { if (!type) {
static const GTypeInfo info = { static const GTypeInfo info = {
sizeof (NotmuchFilterDiscardNonTermClass), .class_size = sizeof (NotmuchFilterDiscardNonTermClass),
NULL, /* base_class_init */ .base_init = NULL,
NULL, /* base_class_finalize */ .base_finalize = NULL,
(GClassInitFunc) notmuch_filter_discard_non_term_class_init, .class_init = (GClassInitFunc) notmuch_filter_discard_non_term_class_init,
NULL, /* class_finalize */ .class_finalize = NULL,
NULL, /* class_data */ .class_data = NULL,
sizeof (NotmuchFilterDiscardNonTerm), .instance_size = sizeof (NotmuchFilterDiscardNonTerm),
0, /* n_preallocs */ .n_preallocs = 0,
NULL, /* instance_init */ .instance_init = NULL,
NULL /* value_table */ .value_table = NULL,
}; };
type = g_type_register_static (GMIME_TYPE_FILTER, "NotmuchFilterDiscardNonTerm", &info, (GTypeFlags) 0); type = g_type_register_static (GMIME_TYPE_FILTER, "NotmuchFilterDiscardNonTerm", &info, (GTypeFlags) 0);