summaryrefslogtreecommitdiff
path: root/telepathy-glib
diff options
context:
space:
mode:
authorAlexander Akulich <akulichalexander@gmail.com>2021-01-26 18:23:28 +0300
committerAlexander Akulich <akulichalexander@gmail.com>2021-01-26 18:23:28 +0300
commitc5c0ed20267d530da5f8084d4fac664d95f31111 (patch)
tree5ca44db1e8a71058ceacfff7869c740c905cae6c /telepathy-glib
parent2ec2564642ca3c3e84cc7fc0c29c5da2567201dd (diff)
parent9c6c6fb5203d8cb73064a02cc6b147aa91908952 (diff)
downloadtelepathy-glib-c5c0ed20267d530da5f8084d4fac664d95f31111.tar.gz
Merge 'master' into telepathy-glib-0.24 (the branch has only fixes)
Diffstat (limited to 'telepathy-glib')
-rw-r--r--telepathy-glib/Makefile.am2
-rw-r--r--telepathy-glib/base-password-channel.c3
-rw-r--r--telepathy-glib/call-channel.c2
-rw-r--r--telepathy-glib/debug-sender.c7
-rw-r--r--telepathy-glib/protocol.c4
-rw-r--r--telepathy-glib/util.h5
-rw-r--r--telepathy-glib/verify.h146
7 files changed, 18 insertions, 151 deletions
diff --git a/telepathy-glib/Makefile.am b/telepathy-glib/Makefile.am
index ce60d7d0b..fe642b29b 100644
--- a/telepathy-glib/Makefile.am
+++ b/telepathy-glib/Makefile.am
@@ -144,7 +144,7 @@ our_headers = \
tpginclude_HEADERS = \
$(our_headers) \
- verify.h
+ $(NULL)
BUILT_SOURCES = $(codegen_sources)
diff --git a/telepathy-glib/base-password-channel.c b/telepathy-glib/base-password-channel.c
index 7ca4ca270..93d37db85 100644
--- a/telepathy-glib/base-password-channel.c
+++ b/telepathy-glib/base-password-channel.c
@@ -387,11 +387,12 @@ tp_base_password_channel_class_init (TpBasePasswordChannelClass *tp_base_passwor
/**
* TpBasePasswordChannel::finished:
+ * @self: the #TpBasePasswordChannel
* @password: the password provided by the user, or %NULL if the
* authentication has been aborted
* @domain: domain of a #GError indicating why the authentication has been
* aborted, or 0
- * @code: error code of a GError indicating why the authentication has been
+ * @code: error code of a #GError indicating why the authentication has been
* aborted, or 0
* @message: a message associated with the error, or %NULL
*
diff --git a/telepathy-glib/call-channel.c b/telepathy-glib/call-channel.c
index 8ed76323b..2a1fa203d 100644
--- a/telepathy-glib/call-channel.c
+++ b/telepathy-glib/call-channel.c
@@ -525,6 +525,8 @@ update_call_members (TpCallChannel *self,
_tp_channel_contacts_queue_prepare_async ((TpChannel *) self,
contacts, update_call_members_prepared_cb, data);
+
+ g_ptr_array_unref (contacts);
}
static void
diff --git a/telepathy-glib/debug-sender.c b/telepathy-glib/debug-sender.c
index 599d9672a..1a5047109 100644
--- a/telepathy-glib/debug-sender.c
+++ b/telepathy-glib/debug-sender.c
@@ -82,6 +82,7 @@ struct _TpDebugSenderPrivate
gboolean enabled;
gboolean timestamps;
GQueue *messages;
+ GMutex messages_lock;
};
typedef struct {
@@ -192,7 +193,9 @@ tp_debug_sender_finalize (GObject *object)
{
TpDebugSender *self = TP_DEBUG_SENDER (object);
+ g_mutex_lock (&self->priv->messages_lock);
g_queue_foreach (self->priv->messages, (GFunc) debug_message_free, NULL);
+ g_mutex_unlock (&self->priv->messages_lock);
g_queue_free (self->priv->messages);
self->priv->messages = NULL;
@@ -288,6 +291,7 @@ get_messages (TpSvcDebug *self,
GList *i;
guint j;
+ g_mutex_lock (&dbg->priv->messages_lock);
messages = g_ptr_array_sized_new (g_queue_get_length (dbg->priv->messages));
for (i = dbg->priv->messages->head; i; i = i->next)
@@ -306,6 +310,7 @@ get_messages (TpSvcDebug *self,
G_MAXUINT);
g_ptr_array_add (messages, g_value_get_boxed (&gvalue));
}
+ g_mutex_unlock (&dbg->priv->messages_lock);
tp_svc_debug_return_from_get_messages (context, messages);
@@ -360,6 +365,7 @@ _tp_debug_sender_take (TpDebugSender *self,
DebugMessage *new_msg)
{
#ifdef ENABLE_DEBUG_CACHE
+ g_mutex_lock (&self->priv->messages_lock);
if (g_queue_get_length (self->priv->messages) >= DEBUG_MESSAGE_LIMIT)
{
DebugMessage *old_head =
@@ -369,6 +375,7 @@ _tp_debug_sender_take (TpDebugSender *self,
}
g_queue_push_tail (self->priv->messages, new_msg);
+ g_mutex_unlock (&self->priv->messages_lock);
#endif
if (self->priv->enabled)
diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c
index b63730cd1..88fdff382 100644
--- a/telepathy-glib/protocol.c
+++ b/telepathy-glib/protocol.c
@@ -1791,7 +1791,7 @@ _tp_protocol_parse_manager_file (GKeyFile *file,
i++;
}
- param_specs = g_ptr_array_sized_new (i);
+ param_specs = g_ptr_array_new_full (i, tp_value_array_free);
for (key = keys; key != NULL && *key != NULL; key++)
{
@@ -1886,6 +1886,8 @@ _tp_protocol_parse_manager_file (GKeyFile *file,
TP_PROP_PROTOCOL_PARAMETERS, TP_ARRAY_TYPE_PARAM_SPEC_LIST, param_specs,
NULL);
+ g_ptr_array_unref(param_specs);
+
tp_asv_take_boxed (immutables, TP_PROP_PROTOCOL_INTERFACES, G_TYPE_STRV,
g_key_file_get_string_list (file, group, "Interfaces", NULL, NULL));
tp_asv_take_boxed (immutables, TP_PROP_PROTOCOL_CONNECTION_INTERFACES,
diff --git a/telepathy-glib/util.h b/telepathy-glib/util.h
index af63a3a99..4c26d733c 100644
--- a/telepathy-glib/util.h
+++ b/telepathy-glib/util.h
@@ -30,9 +30,10 @@
#include <gio/gio.h>
#include <telepathy-glib/defs.h>
-#include <telepathy-glib/verify.h>
-#define tp_verify_statement(R) ((void) tp_verify_true (R))
+#define tp_verify_statement(R) ((void) G_STATIC_ASSERT_EXPR (R))
+#define tp_verify_true(R) (((void) G_STATIC_ASSERT_EXPR (R)), 1)
+#define tp_verify(R) G_STATIC_ASSERT (R)
G_BEGIN_DECLS
diff --git a/telepathy-glib/verify.h b/telepathy-glib/verify.h
deleted file mode 100644
index d46a46013..000000000
--- a/telepathy-glib/verify.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/* Compile-time assert-like macros.
-
- Imported from gnulib 20090701 and adapted to Telepathy namespace.
-
- Copyright (C) 2005, 2006 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
-
-#ifndef __TP_IN_UTIL_H__
-#error Not to be used directly, #include <telepathy-glib/util.h> instead
-#endif
-
-#ifndef TP_VERIFY_H
-# define TP_VERIFY_H 1
-
-/* Each of these macros verifies that its argument R is nonzero. To
- be portable, R should be an integer constant expression. Unlike
- assert (R), there is no run-time overhead.
-
- There are two macros, since no single macro can be used in all
- contexts in C. verify_true (R) is for scalar contexts, including
- integer constant expression contexts. verify (R) is for declaration
- contexts, e.g., the top level.
-
- Symbols ending in "__" are private to this header.
-
- The code below uses several ideas.
-
- * The first step is ((R) ? 1 : -1). Given an expression R, of
- integral or boolean or floating-point type, this yields an
- expression of integral type, whose value is later verified to be
- constant and nonnegative.
-
- * Next this expression W is wrapped in a type
- struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }.
- If W is negative, this yields a compile-time error. No compiler can
- deal with a bit-field of negative size.
-
- One might think that an array size check would have the same
- effect, that is, that the type struct { unsigned int dummy[W]; }
- would work as well. However, inside a function, some compilers
- (such as C++ compilers and GNU C) allow local parameters and
- variables inside array size expressions. With these compilers,
- an array size check would not properly diagnose this misuse of
- the verify macro:
-
- void function (int n) { verify (n < 0); }
-
- * For the verify macro, the struct verify_type__ will need to
- somehow be embedded into a declaration. To be portable, this
- declaration must declare an object, a constant, a function, or a
- typedef name. If the declared entity uses the type directly,
- such as in
-
- struct dummy {...};
- typedef struct {...} dummy;
- extern struct {...} *dummy;
- extern void dummy (struct {...} *);
- extern struct {...} *dummy (void);
-
- two uses of the verify macro would yield colliding declarations
- if the entity names are not disambiguated. A workaround is to
- attach the current line number to the entity name:
-
- #define GL_CONCAT0(x, y) x##y
- #define GL_CONCAT(x, y) GL_CONCAT0 (x, y)
- extern struct {...} * GL_CONCAT(dummy,__LINE__);
-
- But this has the problem that two invocations of verify from
- within the same macro would collide, since the __LINE__ value
- would be the same for both invocations.
-
- A solution is to use the sizeof operator. It yields a number,
- getting rid of the identity of the type. Declarations like
-
- extern int dummy [sizeof (struct {...})];
- extern void dummy (int [sizeof (struct {...})]);
- extern int (*dummy (void)) [sizeof (struct {...})];
-
- can be repeated.
-
- * Should the implementation use a named struct or an unnamed struct?
- Which of the following alternatives can be used?
-
- extern int dummy [sizeof (struct {...})];
- extern int dummy [sizeof (struct verify_type__ {...})];
- extern void dummy (int [sizeof (struct {...})]);
- extern void dummy (int [sizeof (struct verify_type__ {...})]);
- extern int (*dummy (void)) [sizeof (struct {...})];
- extern int (*dummy (void)) [sizeof (struct verify_type__ {...})];
-
- In the second and sixth case, the struct type is exported to the
- outer scope; two such declarations therefore collide. GCC warns
- about the first, third, and fourth cases. So the only remaining
- possibility is the fifth case:
-
- extern int (*dummy (void)) [sizeof (struct {...})];
-
- * This implementation exploits the fact that GCC does not warn about
- the last declaration mentioned above. If a future version of GCC
- introduces a warning for this, the problem could be worked around
- by using code specialized to GCC, e.g.,:
-
- #if 4 <= __GNUC__
- # define verify(R) \
- extern int (* verify_function__ (void)) \
- [__builtin_constant_p (R) && (R) ? 1 : -1]
- #endif
-
- * In C++, any struct definition inside sizeof is invalid.
- Use a template type to work around the problem. */
-
-
-/* Verify requirement R at compile-time, as an integer constant expression.
- Return 1. */
-
-# ifdef __cplusplus
-template <int w>
- struct tp_verify_type__ { unsigned int verify_error_if_negative_size__: w; };
-# define tp_verify_true(R) \
- (!!sizeof (tp_verify_type__<(R) ? 1 : -1>))
-# else
-# define tp_verify_true(R) \
- (!!sizeof \
- (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; }))
-# endif
-
-/* Verify requirement R at compile-time, as a declaration without a
- trailing ';'. */
-
-# define tp_verify(R) extern int (* tp_verify_function__ (void)) [tp_verify_true (R)]
-
-#endif