Skip to content

Commit 0a99147

Browse files
committed
uplink: convert 'flags' to array
Treat 'flags' as array of bits, so that Coverity does not complain about singleton use with atomic_*_bit() API usage. Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
1 parent 3553bbd commit 0a99147

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

gateway/src/uplink.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct pouch_uplink
3434
{
3535
struct gateway_uplink *session;
3636
uint32_t block_idx;
37-
atomic_t flags;
37+
atomic_t flags[1];
3838
struct pouch_block *wblock;
3939
struct pouch_block *rblock;
4040
sys_slist_t queue;
@@ -71,7 +71,7 @@ static void block_upload_callback(struct golioth_client *client,
7171
{
7272
struct pouch_uplink *uplink = arg;
7373

74-
if (!atomic_test_and_clear_bit(&uplink->flags, POUCH_UPLINK_SENDING))
74+
if (!atomic_test_and_clear_bit(uplink->flags, POUCH_UPLINK_SENDING))
7575
{
7676
LOG_ERR("Not sending");
7777
return;
@@ -93,13 +93,13 @@ static void block_upload_callback(struct golioth_client *client,
9393
static void process_uplink(struct pouch_uplink *uplink)
9494
{
9595
enum golioth_status status;
96-
if (atomic_test_and_set_bit(&uplink->flags, POUCH_UPLINK_SENDING))
96+
if (atomic_test_and_set_bit(uplink->flags, POUCH_UPLINK_SENDING))
9797
{
9898
LOG_DBG("Already processing queue");
9999
return;
100100
}
101101

102-
bool closed = atomic_test_bit(&uplink->flags, POUCH_UPLINK_CLOSED);
102+
bool closed = atomic_test_bit(uplink->flags, POUCH_UPLINK_CLOSED);
103103

104104
sys_snode_t *n = sys_slist_get(&uplink->queue);
105105
if (n == NULL)
@@ -111,7 +111,7 @@ static void process_uplink(struct pouch_uplink *uplink)
111111
return;
112112
}
113113

114-
atomic_clear_bit(&uplink->flags, POUCH_UPLINK_SENDING);
114+
atomic_clear_bit(uplink->flags, POUCH_UPLINK_SENDING);
115115
return;
116116
}
117117

@@ -130,7 +130,7 @@ static void process_uplink(struct pouch_uplink *uplink)
130130

131131
free(uplink->rblock);
132132
uplink->rblock = NULL;
133-
atomic_clear_bit(&uplink->flags, POUCH_UPLINK_SENDING);
133+
atomic_clear_bit(uplink->flags, POUCH_UPLINK_SENDING);
134134

135135
return;
136136
}
@@ -248,15 +248,15 @@ struct pouch_uplink *pouch_uplink_open(struct downlink_context *downlink)
248248

249249
uplink->rblock = NULL;
250250
uplink->block_idx = 0;
251-
atomic_set(&uplink->flags, 0);
251+
atomic_set(uplink->flags, 0);
252252
sys_slist_init(&uplink->queue);
253253

254254
return uplink;
255255
}
256256

257257
void pouch_uplink_close(struct pouch_uplink *uplink)
258258
{
259-
bool closed = atomic_test_and_set_bit(&uplink->flags, POUCH_UPLINK_CLOSED);
259+
bool closed = atomic_test_and_set_bit(uplink->flags, POUCH_UPLINK_CLOSED);
260260

261261
if (!closed && uplink->wblock != NULL)
262262
{

0 commit comments

Comments
 (0)