[vlc-commits] [Git][videolan/vlc][master] 4 commits: avahi: use ARRAY_SIZE when suited
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu May 23 10:17:52 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
1842e661 by Alexandre Janniaux at 2024-05-23T09:44:18+00:00
avahi: use ARRAY_SIZE when suited
- - - - -
73dd4d7c by Alexandre Janniaux at 2024-05-23T09:44:18+00:00
avahi: use size_t for subscripting
- - - - -
4d790396 by Alexandre Janniaux at 2024-05-23T09:44:18+00:00
microdns: use ARRAY_SIZE when suited
- - - - -
c921bd77 by Alexandre Janniaux at 2024-05-23T09:44:18+00:00
microdns: use size_t for subscripting
- - - - -
2 changed files:
- modules/services_discovery/avahi.c
- modules/services_discovery/microdns.c
Changes:
=====================================
modules/services_discovery/avahi.c
=====================================
@@ -100,7 +100,6 @@ static const struct
{ "rtsp", "_rtsp._tcp", false },
{ "chromecast", "_googlecast._tcp", true },
};
-#define NB_PROTOCOLS (sizeof(protocols) / sizeof(*protocols))
static char* get_string_list_value( AvahiStringList* txt, const char* key )
{
@@ -269,7 +268,7 @@ static void resolve_callback(
msg_Dbg( p_sys->parent, "service '%s' of type '%s' in domain '%s' port %i",
name, type, domain, port );
- avahi_address_snprint(a, (sizeof(a)/sizeof(a[0]))-1, address);
+ avahi_address_snprint(a, sizeof(a)-1, address);
if( protocol == AVAHI_PROTO_INET6 )
if( asprintf( &psz_addr, "[%s]", a ) == -1 )
{
@@ -279,7 +278,7 @@ static void resolve_callback(
const char *psz_protocol = NULL;
bool is_renderer = false;
- for( unsigned int i = 0; i < NB_PROTOCOLS; i++ )
+ for (size_t i = 0; i < ARRAY_SIZE(protocols); i++)
{
if( !strcmp(type, protocols[i].psz_service_name) )
{
@@ -455,7 +454,7 @@ static int OpenCommon( discovery_sys_t *p_sys )
goto error;
}
- for( unsigned i = 0; i < NB_PROTOCOLS; i++ )
+ for (size_t i = 0; i < ARRAY_SIZE(protocols); i++)
{
if( protocols[i].b_renderer != p_sys->renderer )
continue;
=====================================
modules/services_discovery/microdns.c
=====================================
@@ -85,14 +85,13 @@ static const struct
{ "rtsp", "_rtsp._tcp.local", false, 0 },
{ "chromecast", "_googlecast._tcp.local", true, VLC_RENDERER_CAN_AUDIO },
};
-#define NB_PROTOCOLS (sizeof(protocols) / sizeof(*protocols))
struct discovery_sys
{
vlc_thread_t thread;
atomic_bool stop;
struct mdns_ctx * p_microdns;
- const char * ppsz_service_names[NB_PROTOCOLS];
+ const char * ppsz_service_names[ARRAY_SIZE(protocols)];
unsigned int i_nb_service_names;
vlc_array_t items;
};
@@ -314,7 +313,7 @@ parse_entries( const struct rr_entry *p_entries, bool b_renderer,
{
if( p_entry->type == RR_SRV )
{
- for( unsigned i = 0; i < NB_PROTOCOLS; ++i )
+ for (size_t i = 0; i < ARRAY_SIZE(protocols); ++i)
{
if( !strrcmp( p_entry->name, protocols[i].psz_service_name ) &&
protocols[i].b_renderer == b_renderer )
@@ -589,7 +588,7 @@ OpenCommon( vlc_object_t *p_obj, struct discovery_sys *p_sys, bool b_renderer )
vlc_array_init( &p_sys->items );
/* Listen to protocols that are handled by VLC */
- for( unsigned int i = 0; i < NB_PROTOCOLS; ++i )
+ for (size_t i = 0; i < ARRAY_SIZE(protocols); ++i)
{
if( protocols[i].b_renderer == b_renderer )
p_sys->ppsz_service_names[p_sys->i_nb_service_names++] =
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ceae7711b649738f06188f906b7782258222c090...c921bd77003592fbde929ded42c86b2760cdcda1
--
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ceae7711b649738f06188f906b7782258222c090...c921bd77003592fbde929ded42c86b2760cdcda1
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list