[Replicant] [libsamsung-ipc][PATCH 19/53] samsung-ipc: sms: switch to Linux code style

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Thu Jun 11 10:57:21 UTC 2020


This contains no functional changes.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 samsung-ipc/sms.c | 240 ++++++++++++++++++++++++++--------------------
 1 file changed, 135 insertions(+), 105 deletions(-)

diff --git a/samsung-ipc/sms.c b/samsung-ipc/sms.c
index a93c5d9..ba4c159 100644
--- a/samsung-ipc/sms.c
+++ b/samsung-ipc/sms.c
@@ -23,188 +23,218 @@
 
 #include <samsung-ipc.h>
 
-size_t ipc_sms_send_msg_size_setup(struct ipc_sms_send_msg_request_header *header,
-    const void *smsc, size_t smsc_size, const void *pdu, size_t pdu_size)
+size_t ipc_sms_send_msg_size_setup(
+	struct ipc_sms_send_msg_request_header *header,
+	const void *smsc, size_t smsc_size, const void *pdu, size_t pdu_size)
 {
-    size_t size;
+	size_t size;
 
-	if (header == NULL || smsc == NULL || smsc_size == 0 || pdu == NULL || pdu_size == 0)
+	if (header == NULL || smsc == NULL || smsc_size == 0 || pdu == NULL ||
+	    pdu_size == 0) {
 		return 0;
+	}
 
-    size = sizeof(struct ipc_sms_send_msg_request_header) + sizeof(unsigned char) + smsc_size + pdu_size;
+	size = sizeof(struct ipc_sms_send_msg_request_header) +
+		sizeof(unsigned char) + smsc_size + pdu_size;
 
-    return size;
+	return size;
 }
 
 void *ipc_sms_send_msg_setup(struct ipc_sms_send_msg_request_header *header,
-    const void *smsc, size_t smsc_size, const void *pdu, size_t pdu_size)
+			     const void *smsc, size_t smsc_size,
+			     const void *pdu, size_t pdu_size)
 {
-    void *data;
-    size_t size;
-    unsigned char smsc_length;
-    unsigned char *p;
+	void *data;
+	size_t size;
+	unsigned char smsc_length;
+	unsigned char *p;
 
-	if (header == NULL || smsc == NULL || smsc_size == 0 || pdu == NULL || pdu_size == 0)
+	if (header == NULL || smsc == NULL || smsc_size == 0 || pdu == NULL ||
+	    pdu_size == 0) {
 		return NULL;
+	}
 
-    smsc_length = (unsigned char) smsc_size;
+	smsc_length = (unsigned char) smsc_size;
 
-    header->length = (unsigned char) (sizeof(unsigned char) + smsc_size + pdu_size);
+	header->length = (unsigned char) (
+		sizeof(unsigned char) + smsc_size + pdu_size);
 
-    size = ipc_sms_send_msg_size_setup(header, smsc, smsc_size, pdu, pdu_size);
-    if (size == 0)
-        return NULL;
+	size = ipc_sms_send_msg_size_setup(header, smsc, smsc_size, pdu,
+					   pdu_size);
+	if (size == 0)
+		return NULL;
 
-    data = calloc(1, size);
+	data = calloc(1, size);
 
-    p = (unsigned char *) data;
+	p = (unsigned char *) data;
 
-    memcpy(p, header, sizeof(struct ipc_sms_send_msg_request_header));
-    p += sizeof(struct ipc_sms_send_msg_request_header);
+	memcpy(p, header, sizeof(struct ipc_sms_send_msg_request_header));
+	p += sizeof(struct ipc_sms_send_msg_request_header);
 
-    memcpy(p, &smsc_length, sizeof(smsc_length));
-    p += sizeof(smsc_length);
+	memcpy(p, &smsc_length, sizeof(smsc_length));
+	p += sizeof(smsc_length);
 
-    memcpy(p, smsc, smsc_size);
-    p += smsc_size;
+	memcpy(p, smsc, smsc_size);
+	p += smsc_size;
 
-    memcpy(p, pdu, pdu_size);
-    p += pdu_size;
+	memcpy(p, pdu, pdu_size);
+	p += pdu_size;
 
-    return data;
+	return data;
 }
 
 size_t ipc_sms_incoming_msg_pdu_size_extract(const void *data, size_t size)
 {
-    struct ipc_sms_incoming_msg_header *header;
+	struct ipc_sms_incoming_msg_header *header;
 
-    header = (struct ipc_sms_incoming_msg_header *) data;
-    if (header->length == 0 || header->length > size - sizeof(struct ipc_sms_incoming_msg_header))
-        return 0;
+	header = (struct ipc_sms_incoming_msg_header *) data;
+	if (header->length == 0 ||
+	    header->length > size -
+	    sizeof(struct ipc_sms_incoming_msg_header)) {
+		return 0;
+	}
 
-    return (size_t) header->length;
+	return (size_t) header->length;
 }
 
 void *ipc_sms_incoming_msg_pdu_extract(const void *data, size_t size)
 {
-    struct ipc_sms_incoming_msg_header *header;
-    void *pdu;
+	struct ipc_sms_incoming_msg_header *header;
+	void *pdu;
 
-    if (data == NULL || size < sizeof(struct ipc_sms_incoming_msg_header))
-        return NULL;
+	if (data == NULL || size < sizeof(struct ipc_sms_incoming_msg_header))
+		return NULL;
 
-    header = (struct ipc_sms_incoming_msg_header *) data;
-    if (header->length == 0 || header->length > size - sizeof(struct ipc_sms_incoming_msg_header))
-        return NULL;
+	header = (struct ipc_sms_incoming_msg_header *) data;
+	if (header->length == 0 ||
+	    header->length > size -
+	    sizeof(struct ipc_sms_incoming_msg_header)) {
+		return NULL;
+	}
 
-    pdu = (void *) ((unsigned char *) data + sizeof(struct ipc_sms_incoming_msg_header));
+	pdu = (void *) ((unsigned char *) data +
+			sizeof(struct ipc_sms_incoming_msg_header));
 
-    return pdu;
+	return pdu;
 }
 
-size_t ipc_sms_save_msg_size_setup(struct ipc_sms_save_msg_request_header *header,
-    const void *smsc, size_t smsc_size, const void *pdu, size_t pdu_size)
+size_t ipc_sms_save_msg_size_setup(
+	struct ipc_sms_save_msg_request_header *header,
+	const void *smsc, size_t smsc_size, const void *pdu, size_t pdu_size)
 {
-    size_t size;
+	size_t size;
 
-    if (header == NULL || pdu == NULL || pdu_size == 0)
-        return 0;
+	if (header == NULL || pdu == NULL || pdu_size == 0)
+		return 0;
 
-    if (smsc == NULL)
-        smsc_size = 0;
+	if (smsc == NULL)
+		smsc_size = 0;
 
-    size = sizeof(struct ipc_sms_save_msg_request_header) + sizeof(unsigned char) + smsc_size + pdu_size;
+	size = sizeof(struct ipc_sms_save_msg_request_header) +
+		sizeof(unsigned char) + smsc_size + pdu_size;
 
-    return size;
+	return size;
 }
 
 void *ipc_sms_save_msg_setup(struct ipc_sms_save_msg_request_header *header,
-    const void *smsc, size_t smsc_size, const void *pdu, size_t pdu_size)
+			     const void *smsc, size_t smsc_size,
+			     const void *pdu, size_t pdu_size)
 {
-    void *data;
-    size_t size;
-    unsigned char smsc_length;
-    unsigned char *p;
+	void *data;
+	size_t size;
+	unsigned char smsc_length;
+	unsigned char *p;
 
-    if (header == NULL || pdu == NULL || pdu_size == 0)
-        return NULL;
+	if (header == NULL || pdu == NULL || pdu_size == 0)
+		return NULL;
 
-    if (smsc == NULL)
-        smsc_size = 0;
+	if (smsc == NULL)
+		smsc_size = 0;
 
-    smsc_length = (unsigned char) smsc_size;
+	smsc_length = (unsigned char) smsc_size;
 
-    header->magic = 2;
-    header->index = 12 - 1,
-    header->length = (unsigned char) (sizeof(unsigned char) + smsc_size + pdu_size);
+	header->magic = 2;
+	header->index = 12 - 1,
+		header->length = (unsigned char) (
+			sizeof(unsigned char) + smsc_size + pdu_size);
 
-    size = ipc_sms_save_msg_size_setup(header, smsc, smsc_size, pdu, pdu_size);
-    if (size == 0)
-        return NULL;
+	size = ipc_sms_save_msg_size_setup(header, smsc, smsc_size, pdu,
+					   pdu_size);
+	if (size == 0)
+		return NULL;
 
-    data = calloc(1, size);
+	data = calloc(1, size);
 
-    p = (unsigned char *) data;
+	p = (unsigned char *) data;
 
-    memcpy(p, header, sizeof(struct ipc_sms_save_msg_request_header));
-    p += sizeof(struct ipc_sms_save_msg_request_header);
+	memcpy(p, header, sizeof(struct ipc_sms_save_msg_request_header));
+	p += sizeof(struct ipc_sms_save_msg_request_header);
 
-    memcpy(p, &smsc_length, sizeof(smsc_length));
-    p += sizeof(smsc_length);
+	memcpy(p, &smsc_length, sizeof(smsc_length));
+	p += sizeof(smsc_length);
 
-    if (smsc != NULL && smsc_size > 0) {
-        memcpy(p, smsc, smsc_size);
-        p += smsc_size;
-    }
+	if (smsc != NULL && smsc_size > 0) {
+		memcpy(p, smsc, smsc_size);
+		p += smsc_size;
+	}
 
-    memcpy(p, pdu, pdu_size);
-    p += pdu_size;
+	memcpy(p, pdu, pdu_size);
+	p += pdu_size;
 
-    return data;
+	return data;
 }
 
 int ipc_sms_del_msg_setup(struct ipc_sms_del_msg_request_data *data,
-    unsigned short index)
+			  unsigned short index)
 {
-   if (data == NULL)
-        return -1;
+	if (data == NULL)
+		return -1;
 
-    memset(data, 0, sizeof(struct ipc_sms_del_msg_request_data));
-    data->magic = 2;
-    data->index = index;
+	memset(data, 0, sizeof(struct ipc_sms_del_msg_request_data));
+	data->magic = 2;
+	data->index = index;
 
-    return 0;
+	return 0;
 }
 
 size_t ipc_sms_svc_center_addr_smsc_size_extract(const void *data, size_t size)
 {
-    struct ipc_sms_svc_center_addr_header *header;
+	struct ipc_sms_svc_center_addr_header *header;
 
-    if (data == NULL || size < sizeof(struct ipc_sms_svc_center_addr_header))
-        return 0;
+	if (data == NULL ||
+	    size < sizeof(struct ipc_sms_svc_center_addr_header)) {
+		return 0;
+	}
 
-    header = (struct ipc_sms_svc_center_addr_header *) data;
-    if (header->length == 0 || header->length > size - sizeof(struct ipc_sms_svc_center_addr_header))
-        return 0;
+	header = (struct ipc_sms_svc_center_addr_header *) data;
+	if (header->length == 0 ||
+	    header->length > size -
+	    sizeof(struct ipc_sms_svc_center_addr_header)) {
+		return 0;
+	}
 
-    return (size_t) header->length;
+	return (size_t) header->length;
 }
 
 void *ipc_sms_svc_center_addr_smsc_extract(const void *data, size_t size)
 {
-    struct ipc_sms_svc_center_addr_header *header;
-    void *smsc;
+	struct ipc_sms_svc_center_addr_header *header;
+	void *smsc;
 
-    if (data == NULL || size < sizeof(struct ipc_sms_svc_center_addr_header))
-        return NULL;
+	if (data == NULL ||
+	    size < sizeof(struct ipc_sms_svc_center_addr_header)) {
+		return NULL;
+	}
 
-    header = (struct ipc_sms_svc_center_addr_header *) data;
-    if (header->length == 0 || header->length > size - sizeof(struct ipc_sms_svc_center_addr_header))
-        return NULL;
+	header = (struct ipc_sms_svc_center_addr_header *) data;
+	if (header->length == 0 ||
+	    header->length > size -
+	    sizeof(struct ipc_sms_svc_center_addr_header)) {
+		return NULL;
+	}
 
-    smsc = (void *) ((unsigned char *) data + sizeof(struct ipc_sms_svc_center_addr_header));
+	smsc = (void *) ((unsigned char *) data +
+			 sizeof(struct ipc_sms_svc_center_addr_header));
 
-    return smsc;
+	return smsc;
 }
-
-// vim:ts=4:sw=4:expandtab
-- 
2.27.0



More information about the Replicant mailing list