Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
cleanup: use tvh_uuid_t instead uint8_t array for idnode_t
  • Loading branch information
perexg committed Jan 13, 2016
1 parent 5ed2055 commit b091feb
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/channels.c
Expand Up @@ -497,7 +497,7 @@ channel_t *
channel_find_by_id ( uint32_t i )
{
channel_t skel;
memcpy(skel.ch_id.in_uuid, &i, sizeof(i));
memcpy(skel.ch_id.in_uuid.bin, &i, sizeof(i));

return RB_FIND(&channels, &skel, ch_link, ch_id_cmp);
}
Expand Down
10 changes: 5 additions & 5 deletions src/idnode.c
Expand Up @@ -57,7 +57,7 @@ SKEL_DECLARE(idclasses_skel, idclass_link_t);
static int
in_cmp(const idnode_t *a, const idnode_t *b)
{
return memcmp(a->in_uuid, b->in_uuid, sizeof(a->in_uuid));
return uuid_cmp(&a->in_uuid, &b->in_uuid);
}

static int
Expand Down Expand Up @@ -131,7 +131,7 @@ idnode_insert(idnode_t *in, const char *uuid, const idclass_t *class, int flags)
in->in_class = NULL;
return -1;
}
memcpy(in->in_uuid, u.bin, sizeof(in->in_uuid));
uuid_copy(&in->in_uuid, &u);

c = NULL;
if (flags & IDNODE_SHORT_UUID) {
Expand Down Expand Up @@ -234,7 +234,7 @@ uint32_t
idnode_get_short_uuid (const idnode_t *in)
{
uint32_t u32;
memcpy(&u32, in->in_uuid, sizeof(u32));
memcpy(&u32, in->in_uuid.bin, sizeof(u32));
return u32 & 0x7FFFFFFF; // compat needs to be +ve signed
}

Expand All @@ -244,7 +244,7 @@ idnode_get_short_uuid (const idnode_t *in)
const char *
idnode_uuid_as_str(const idnode_t *in, char *uuid)
{
bin2hex(uuid, UUID_HEX_SIZE, in->in_uuid, sizeof(in->in_uuid));
bin2hex(uuid, UUID_HEX_SIZE, in->in_uuid.bin, sizeof(in->in_uuid.bin));
return uuid;
}

Expand Down Expand Up @@ -608,7 +608,7 @@ idnode_find ( const char *uuid, const idclass_t *idc, const idnodes_rb_t *domain
tvhtrace("idnode", "find node %s class %s", uuid, idc ? idc->ic_class : NULL);
if(uuid == NULL || strlen(uuid) != UUID_HEX_SIZE - 1)
return NULL;
if(hex2bin(skel.in_uuid, sizeof(skel.in_uuid), uuid))
if(hex2bin(skel.in_uuid.bin, sizeof(skel.in_uuid.bin), uuid))
return NULL;
if (domain == NULL)
domain = idnode_domain(idc);
Expand Down
2 changes: 1 addition & 1 deletion src/idnode.h
Expand Up @@ -83,7 +83,7 @@ typedef RB_HEAD(, idnode) idnodes_rb_t;
* Node definition
*/
struct idnode {
uint8_t in_uuid[UUID_BIN_SIZE]; ///< Unique ID
tvh_uuid_t in_uuid; ///< Unique ID
RB_ENTRY(idnode) in_link; ///< Global hash
RB_ENTRY(idnode) in_domain_link; ///< Root class link (domain)
idnodes_rb_t *in_domain; ///< Domain nodes
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/satip/satip.c
Expand Up @@ -675,7 +675,7 @@ satip_device_find( const char *satip_uuid )
satip_device_calc_bin_uuid(binuuid, satip_uuid);
TVH_HARDWARE_FOREACH(th) {
if (idnode_is_instance(&th->th_id, &satip_device_class) &&
memcmp(th->th_id.in_uuid, binuuid, UUID_BIN_SIZE) == 0)
memcmp(th->th_id.in_uuid.bin, binuuid, UUID_BIN_SIZE) == 0)
return (satip_device_t *)th;
}
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/tvhdhomerun/tvhdhomerun.c
Expand Up @@ -249,7 +249,7 @@ tvhdhomerun_device_find( uint32_t device_id )
tvhdhomerun_device_calc_bin_uuid(binuuid, device_id);
TVH_HARDWARE_FOREACH(th) {
if (idnode_is_instance(&th->th_id, &tvhdhomerun_device_class) &&
memcmp(th->th_id.in_uuid, binuuid, UUID_BIN_SIZE) == 0)
memcmp(th->th_id.in_uuid.bin, binuuid, UUID_BIN_SIZE) == 0)
return (tvhdhomerun_device_t *)th;
}
return NULL;
Expand Down
16 changes: 16 additions & 0 deletions src/uuid.h
Expand Up @@ -59,6 +59,22 @@ int uuid_bin2hex ( const tvh_uuid_t *a, tvh_uuid_t *b );
*/
int uuid_hex2bin ( const tvh_uuid_t *a, tvh_uuid_t *b );

/**
* Copy
*/
static inline void uuid_copy ( tvh_uuid_t *dst, const tvh_uuid_t *src )
{
*dst = *src;
}

/**
* Compare
*/
static inline int uuid_cmp ( const tvh_uuid_t *a, const tvh_uuid_t *b )
{
return memcmp(a->bin, b->bin, UUID_BIN_SIZE);
}

/**
* Valid hex uuid
*/
Expand Down

0 comments on commit b091feb

Please sign in to comment.