summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2021-04-28 16:38:55 +0200
committerMarcel Holtmann <marcel@holtmann.org>2021-04-28 16:38:55 +0200
commitdbbbebf92d786b089508b70f87532613a3f76a03 (patch)
tree4af89cb4dacdd707d5e7c3733dd7aab860b9ba65
parentb3682c6bab99cbe301fa9bf4a2416c3f730d8bfd (diff)
downloadofono-dbbbebf92d786b089508b70f87532613a3f76a03.tar.gz
mbimmodem: Remove usage of likely and unlikely
-rw-r--r--drivers/mbimmodem/mbim-message.c58
-rw-r--r--drivers/mbimmodem/mbim.c33
2 files changed, 45 insertions, 46 deletions
diff --git a/drivers/mbimmodem/mbim-message.c b/drivers/mbimmodem/mbim-message.c
index 4c7b5854..9f972cb3 100644
--- a/drivers/mbimmodem/mbim-message.c
+++ b/drivers/mbimmodem/mbim-message.c
@@ -501,7 +501,7 @@ static bool message_iter_next_entry_valist(struct mbim_message_iter *orig,
signature += 1;
indent += 1;
- if (unlikely(indent > MAX_NESTING))
+ if (indent > MAX_NESTING)
return false;
if (!_iter_enter_struct(iter, &stack[indent - 1]))
@@ -511,7 +511,7 @@ static bool message_iter_next_entry_valist(struct mbim_message_iter *orig,
break;
case ')':
- if (unlikely(indent == 0))
+ if (indent == 0)
return false;
signature += 1;
@@ -562,7 +562,7 @@ bool mbim_message_iter_next_entry(struct mbim_message_iter *iter, ...)
va_list args;
bool result;
- if (unlikely(!iter))
+ if (!iter)
return false;
va_start(args, iter);
@@ -675,7 +675,7 @@ struct mbim_message *mbim_message_new(const uint8_t *uuid, uint32_t cid,
struct mbim_message *mbim_message_ref(struct mbim_message *msg)
{
- if (unlikely(!msg))
+ if (!msg)
return NULL;
__sync_fetch_and_add(&msg->ref_count, 1);
@@ -687,7 +687,7 @@ void mbim_message_unref(struct mbim_message *msg)
{
unsigned int i;
- if (unlikely(!msg))
+ if (!msg)
return;
if (__sync_sub_and_fetch(&msg->ref_count, 1))
@@ -760,10 +760,10 @@ uint32_t mbim_message_get_error(struct mbim_message *message)
{
struct mbim_message_header *hdr;
- if (unlikely(!message))
+ if (!message)
return false;
- if (unlikely(!message->sealed))
+ if (!message->sealed)
return false;
hdr = (struct mbim_message_header *) message->header;
@@ -776,7 +776,7 @@ uint32_t mbim_message_get_error(struct mbim_message *message)
uint32_t mbim_message_get_cid(struct mbim_message *message)
{
- if (unlikely(!message))
+ if (!message)
return false;
return message->cid;
@@ -784,7 +784,7 @@ uint32_t mbim_message_get_cid(struct mbim_message *message)
const uint8_t *mbim_message_get_uuid(struct mbim_message *message)
{
- if (unlikely(!message))
+ if (!message)
return false;
return message->uuid;
@@ -800,10 +800,10 @@ bool mbim_message_get_arguments(struct mbim_message *message,
uint32_t type;
size_t begin;
- if (unlikely(!message))
+ if (!message)
return false;
- if (unlikely(!message->sealed))
+ if (!message->sealed)
return false;
hdr = (struct mbim_message_header *) message->header;
@@ -834,10 +834,10 @@ static bool _mbim_message_get_data(struct mbim_message *message,
size_t pos;
uint32_t i;
- if (unlikely(!message))
+ if (!message)
return false;
- if (unlikely(!message->sealed))
+ if (!message->sealed)
return false;
hdr = (struct mbim_message_header *) message->header;
@@ -1008,7 +1008,7 @@ struct mbim_message_builder *mbim_message_builder_new(struct mbim_message *msg)
uint32_t type;
struct container *container;
- if (unlikely(!msg))
+ if (!msg)
return NULL;
if (msg->sealed)
@@ -1033,7 +1033,7 @@ void mbim_message_builder_free(struct mbim_message_builder *builder)
{
uint32_t i;
- if (unlikely(!builder))
+ if (!builder)
return;
mbim_message_unref(builder->message);
@@ -1060,10 +1060,10 @@ bool mbim_message_builder_append_basic(struct mbim_message_builder *builder,
size_t len;
uint16_t *utf16;
- if (unlikely(!builder))
+ if (!builder)
return false;
- if (unlikely(!strchr(simple_types, type)))
+ if (!strchr(simple_types, type))
return false;
alignment = get_alignment(type);
@@ -1168,16 +1168,16 @@ bool mbim_message_builder_append_bytes(struct mbim_message_builder *builder,
struct container *container = &builder->stack[builder->index];
size_t start;
- if (unlikely(!builder))
+ if (!builder)
return false;
if (container->container_type == CONTAINER_TYPE_ARRAY) {
struct container *array;
- if (unlikely(container->sigindex != 0))
+ if (container->sigindex != 0)
return false;
- if (unlikely(container->signature[container->sigindex] != 'y'))
+ if (container->signature[container->sigindex] != 'y')
return false;
array = container;
@@ -1247,12 +1247,12 @@ bool mbim_message_builder_leave_struct(struct mbim_message_builder *builder)
struct container *array = NULL;
size_t start;
- if (unlikely(builder->index == 0))
+ if (builder->index == 0)
return false;
container = &builder->stack[builder->index];
- if (unlikely(container->container_type != CONTAINER_TYPE_STRUCT))
+ if (container->container_type != CONTAINER_TYPE_STRUCT)
return false;
builder->index -= 1;
@@ -1339,12 +1339,12 @@ bool mbim_message_builder_leave_array(struct mbim_message_builder *builder)
{
struct container *container;
- if (unlikely(builder->index == 0))
+ if (builder->index == 0)
return false;
container = &builder->stack[builder->index];
- if (unlikely(container->container_type != CONTAINER_TYPE_ARRAY))
+ if (container->container_type != CONTAINER_TYPE_ARRAY)
return false;
builder->index -= 1;
@@ -1381,12 +1381,12 @@ bool mbim_message_builder_leave_databuf(struct mbim_message_builder *builder)
struct container *parent;
size_t start;
- if (unlikely(builder->index == 0))
+ if (builder->index == 0)
return false;
container = &builder->stack[builder->index];
- if (unlikely(container->container_type != CONTAINER_TYPE_DATABUF))
+ if (container->container_type != CONTAINER_TYPE_DATABUF)
return false;
builder->index -= 1;
@@ -1415,7 +1415,7 @@ struct mbim_message *mbim_message_builder_finalize(
struct container *root;
struct mbim_message_header *hdr;
- if (unlikely(!builder))
+ if (!builder)
return NULL;
if (builder->index != 0)
@@ -1701,10 +1701,10 @@ bool mbim_message_set_arguments(struct mbim_message *message,
va_list args;
bool result;
- if (unlikely(!message))
+ if (!message)
return false;
- if (unlikely(message->sealed))
+ if (message->sealed)
return false;
if (!signature)
diff --git a/drivers/mbimmodem/mbim.c b/drivers/mbimmodem/mbim.c
index e5163bc4..9de31eb1 100644
--- a/drivers/mbimmodem/mbim.c
+++ b/drivers/mbimmodem/mbim.c
@@ -183,8 +183,7 @@ static struct mbim_message *message_assembly_add(
struct message_assembly_node *node;
struct mbim_message *message;
- if (unlikely(type != MBIM_COMMAND_DONE &&
- type != MBIM_INDICATE_STATUS_MSG))
+ if (type != MBIM_COMMAND_DONE && type != MBIM_INDICATE_STATUS_MSG)
return NULL;
node = l_queue_find(assembly->transactions,
@@ -894,7 +893,7 @@ struct mbim_device *mbim_device_new(int fd, uint32_t max_segment_size)
{
struct mbim_device *device;
- if (unlikely(fd < 0))
+ if (fd < 0)
return NULL;
device = l_new(struct mbim_device, 1);
@@ -926,7 +925,7 @@ struct mbim_device *mbim_device_new(int fd, uint32_t max_segment_size)
struct mbim_device *mbim_device_ref(struct mbim_device *device)
{
- if (unlikely(!device))
+ if (!device)
return NULL;
__sync_fetch_and_add(&device->ref_count, 1);
@@ -936,7 +935,7 @@ struct mbim_device *mbim_device_ref(struct mbim_device *device)
void mbim_device_unref(struct mbim_device *device)
{
- if (unlikely(!device))
+ if (!device)
return;
if (__sync_sub_and_fetch(&device->ref_count, 1))
@@ -966,7 +965,7 @@ void mbim_device_unref(struct mbim_device *device)
bool mbim_device_shutdown(struct mbim_device *device)
{
- if (unlikely(!device))
+ if (!device)
return false;
l_io_set_read_handler(device->io, close_read_handler, device, NULL);
@@ -978,7 +977,7 @@ bool mbim_device_shutdown(struct mbim_device *device)
bool mbim_device_set_max_outstanding(struct mbim_device *device, uint32_t max)
{
- if (unlikely(!device))
+ if (!device)
return false;
device->max_outstanding = max;
@@ -990,7 +989,7 @@ bool mbim_device_set_disconnect_handler(struct mbim_device *device,
void *user_data,
mbim_device_destroy_func_t destroy)
{
- if (unlikely(!device))
+ if (!device)
return false;
if (device->disconnect_destroy)
@@ -1007,7 +1006,7 @@ bool mbim_device_set_debug(struct mbim_device *device,
mbim_device_debug_func_t func, void *user_data,
mbim_device_destroy_func_t destroy)
{
- if (unlikely(!device))
+ if (!device)
return false;
if (device->debug_destroy)
@@ -1022,7 +1021,7 @@ bool mbim_device_set_debug(struct mbim_device *device,
bool mbim_device_set_close_on_unref(struct mbim_device *device, bool do_close)
{
- if (unlikely(!device))
+ if (!device)
return false;
if (!device->io)
@@ -1037,7 +1036,7 @@ bool mbim_device_set_ready_handler(struct mbim_device *device,
void *user_data,
mbim_device_destroy_func_t destroy)
{
- if (unlikely(!device))
+ if (!device)
return false;
if (device->ready_destroy)
@@ -1058,7 +1057,7 @@ uint32_t mbim_device_send(struct mbim_device *device, uint32_t gid,
{
struct pending_command *pending;
- if (unlikely(!device || !message))
+ if (!device || !message)
return 0;
pending = l_new(struct pending_command, 1);
@@ -1088,7 +1087,7 @@ bool mbim_device_cancel(struct mbim_device *device, uint32_t tid)
{
struct pending_command *pending;
- if (unlikely(!device))
+ if (!device)
return false;
pending = l_queue_remove_if(device->pending_commands,
@@ -1112,7 +1111,7 @@ bool mbim_device_cancel(struct mbim_device *device, uint32_t tid)
bool mbim_device_cancel_group(struct mbim_device *device, uint32_t gid)
{
- if (unlikely(!device))
+ if (!device)
return false;
l_queue_foreach_remove(device->pending_commands,
@@ -1135,7 +1134,7 @@ uint32_t mbim_device_register(struct mbim_device *device, uint32_t gid,
struct notification *notification;
uint32_t id;
- if (unlikely(!device))
+ if (!device)
return 0;
id = device->next_notification;
@@ -1163,7 +1162,7 @@ bool mbim_device_unregister(struct mbim_device *device, uint32_t id)
{
struct notification *notification;
- if (unlikely(!device))
+ if (!device)
return false;
if (device->in_notify) {
@@ -1192,7 +1191,7 @@ bool mbim_device_unregister_group(struct mbim_device *device, uint32_t gid)
const struct l_queue_entry *entry;
bool r;
- if (unlikely(!device))
+ if (!device)
return false;
if (!device->in_notify)