[unique] message: Fix signedness of set() length parameter
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [unique] message: Fix signedness of set() length parameter
- Date: Sun, 27 Mar 2011 08:58:55 +0000 (UTC)
commit b9fba9f38913cf717e11277b3948f9c4effc2f8f
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Sun Mar 27 09:43:05 2011 +0100
message: Fix signedness of set() length parameter
Since we accept -1 as a valid value for unique_message_data_set(), we need
to use gssize and not gsize. We also need to clamp the stored value to 0 in
case of negative values, as other parts of the code expect that.
unique/uniquemessage.c | 6 +++---
unique/uniquemessage.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/unique/uniquemessage.c b/unique/uniquemessage.c
index 262d9fb..a938029 100644
--- a/unique/uniquemessage.c
+++ b/unique/uniquemessage.c
@@ -133,7 +133,7 @@ unique_message_data_free (UniqueMessageData *message_data)
/**
* unique_message_data_set:
* @message_data: a #UniqueMessageData
- * @data: binary blob to set, or %NULL
+ * @data: (allow-none): binary blob to set, or %NULL
* @length: length of @data
*
* Sets @data as the payload of @message_data. Any other data is removed
@@ -146,7 +146,7 @@ unique_message_data_free (UniqueMessageData *message_data)
void
unique_message_data_set (UniqueMessageData *message_data,
const guchar *data,
- gsize length)
+ gssize length)
{
g_return_if_fail (message_data != NULL);
@@ -168,7 +168,7 @@ unique_message_data_set (UniqueMessageData *message_data,
message_data->data = (guchar *) g_strdup ("");
}
- message_data->length = length;
+ message_data->length = length >= 0 ? length : 0;
}
/**
diff --git a/unique/uniquemessage.h b/unique/uniquemessage.h
index d3e9c3c..b862d43 100644
--- a/unique/uniquemessage.h
+++ b/unique/uniquemessage.h
@@ -47,7 +47,7 @@ void unique_message_data_free (UniqueMessageData *me
void unique_message_data_set (UniqueMessageData *message_data,
const guchar *data,
- gsize length);
+ gssize length);
G_CONST_RETURN guchar *unique_message_data_get (UniqueMessageData *message_data,
gsize *length);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]