Skip to content

Commit

Permalink
Fix some compler warnings and build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sidcha committed Jun 28, 2020
1 parent ac125fa commit 7fd7003
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion sample/pd_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include <stdio.h>
#include <unistd.h>
#include <osdp.h>

enum osdp_pd_e {
Expand Down Expand Up @@ -80,7 +81,7 @@ int main()
}

// your application code.
u sleep(1000);
usleep(1000);
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/include/osdp_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
to_cp(p)->pd_offset = i; \
} while (0)
#define AES_PAD_LEN(x) ((x + 16 - 1) & (~(16 - 1)))
#define PD_MASK(ctx) ((1 << (to_cp(ctx)->num_pd + 1)) - 1)
#define PD_MASK(ctx) (uint32_t)((1 << (to_cp(ctx)->num_pd + 1)) - 1)
#define NUM_PD(ctx) (to_cp(ctx)->num_pd)

/* OSDP reserved commands */
Expand Down
4 changes: 2 additions & 2 deletions src/osdp_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ void osdp_slab_del(struct osdp_slab *s)
void *osdp_slab_alloc(struct osdp_slab *s)
{
int i;
uint8_t *p;
uint8_t *p = NULL;

for (i = 0; i < s->num_blocks; i++) {
p = s->blob + (s->block_size * i);
if (*p == 0)
break;
}
if (i == s->num_blocks)
if (p == NULL || i == s->num_blocks)
return NULL;
*p = 1; // Mark as allocated.
*(p + s->block_size - 1) = 0x55; // cookie.
Expand Down
2 changes: 1 addition & 1 deletion src/osdp_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int phy_build_packet_head(struct osdp_pd *p, int id, uint8_t *buf, int maxlen)
pd_mode = isset_flag(p, PD_FLAG_PD_MODE);
exp_len = sizeof(struct osdp_packet_header) + 64; /* estimated cmd len */
if (maxlen < exp_len) {
LOG_N(TAG "pkt_buf len err - %d/%d", maxlen,
LOG_I(TAG "pkt_buf len err - %d/%d", maxlen,
exp_len);
return -1;
}
Expand Down

0 comments on commit 7fd7003

Please sign in to comment.