[gbinder] Housekeeping. JB#54354

This commit is contained in:
Slava Monich
2022-02-20 02:31:56 +02:00
parent 9d95a622f4
commit 3c828b453a
4 changed files with 32 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2018-2021 Jolla Ltd.
* Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2018-2022 Jolla Ltd.
* Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -145,7 +145,7 @@ gbinder_reader_read_buffer(
const void*
gbinder_reader_read_parcelable(
GBinderReader* reader,
gsize* size); /* Since 1.1.XX */
gsize* size); /* Since 1.1.19 */
const void*
gbinder_reader_read_hidl_struct1(

View File

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2018-2021 Jolla Ltd.
* Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2018-2022 Jolla Ltd.
* Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -152,7 +152,7 @@ void
gbinder_writer_append_parcelable(
GBinderWriter* writer,
const void* buf,
gsize len); /* Since 1.1.XX */
gsize len); /* Since 1.1.19 */
void
gbinder_writer_append_hidl_vec(

View File

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2018-2021 Jolla Ltd.
* Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2018-2022 Jolla Ltd.
* Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -427,17 +427,16 @@ gbinder_reader_skip_buffer(
const void*
gbinder_reader_read_parcelable(
GBinderReader* reader,
gsize* size) /* Since 1.1.XX */
gsize* size) /* Since 1.1.19 */
{
GBinderReaderPriv* p = gbinder_reader_cast(reader);
gint32 non_null, payload_size = 0;
const void* out = NULL;
if (gbinder_reader_read_int32(reader, &non_null) && non_null
&& gbinder_reader_read_int32(reader, &payload_size)) {
/* We have already read the size integer, and we don't need it anymore */
if (gbinder_reader_read_int32(reader, &non_null) && non_null &&
gbinder_reader_read_int32(reader, &payload_size)) {
/* We have already read the size integer */
payload_size -= sizeof(gint32);
if (p->ptr + payload_size <= p->end) {
out = p->ptr;
p->ptr += payload_size;

View File

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2018-2021 Jolla Ltd.
* Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2018-2022 Jolla Ltd.
* Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -762,7 +762,7 @@ void
gbinder_writer_append_parcelable(
GBinderWriter* self,
const void* buf,
gsize len) /* Since 1.1.XX */
gsize len) /* Since 1.1.19 */
{
GBinderWriterData* data = gbinder_writer_data(self);
@@ -771,24 +771,32 @@ gbinder_writer_append_parcelable(
}
}
/*
* This is compatible with aidl parcelables, and is not guaranteed to work
* with any other kind of parcelable.
*/
void
gbinder_writer_data_append_parcelable(
GBinderWriterData* data,
const void* ptr,
gsize size)
{
if (!ptr) {
if (ptr) {
/* Non-null */
gbinder_writer_data_append_int32(data, 1);
/*
* Write the parcelable size, taking in account the size of this
* integer as well.
*/
gbinder_writer_data_append_int32(data, size + sizeof(gint32));
/* Append the parcelable data */
g_byte_array_append(data->bytes, ptr, size);
} else {
/* Null */
gbinder_writer_data_append_int32(data, 0);
return;
}
/* Non-null */
gbinder_writer_data_append_int32(data, 1);
/* Write the parcelable size, taking in account the size of this integer as well */
gbinder_writer_data_append_int32(data, size + sizeof(gint32));
/* Append the parcelable data */
g_byte_array_append(data->bytes, ptr, size);
}
void