[ofa-general] [PATCH] Fix umad_get_cas_names() usage in libibumad.
Arne Redlich
arne.redlich at xiranet.com
Mon Sep 17 02:25:08 PDT 2007
Sasha Khapyorsky <sashak at voltaire.com> writes:
> On 17:30 Mon 10 Sep , Arne Redlich wrote:
>> "Hal Rosenstock" <hal.rosenstock at gmail.com> writes:
>>
>> > On 9/7/07, Arne Redlich <arne.redlich at xiranet.com> wrote:
>> >> resolve_ca_name() passes a wrong "max" argument to umad_get_cas_names.
>> >>
>> >> Signed-off-by: Arne Redlich <arne.redlich at xiranet.com>
>> >> ---
>> >> diff --git a/libibumad/src/umad.c b/libibumad/src/umad.c
>> >> index 787aa92..589684c 100644
>> >> --- a/libibumad/src/umad.c
>> >> +++ b/libibumad/src/umad.c
>> >> @@ -307,7 +307,7 @@ resolve_ca_name(char *ca_name, int *best_port)
>> >> }
>> >>
>> >> /* Get the list of CA names */
>> >> - if ((n = umad_get_cas_names((void *)names, UMAD_CA_NAME_LEN)) < 0)
>> >> + if ((n = umad_get_cas_names((void *)names, 20)) < 0)
>> >
>> > Rather than the hard coded 20 here and elsewhere, should this be
>> > replaced by a #define ?
>>
>> How about a umad_get_cas_count() helper instead?
>
> I'm not against using '20' here since this fixed size array is declared
> just few lines above. A helper function could be nicer, but what do
> you mean? Something like (sizeof(names)/UMAD_CA_NAME_LEN)?
No, sorry for being unclear.
What I had in mind was a function that returns the actual number of
CAs in the system, so users of umad_get_cas_names() don't need to take
guesses anymore, i.e.:
nca = umad_get_cas_count();
cas = calloc(nca, UMAD_CA_NAME_LEN);
ret = umad_get_cas_names(cas, nca);
Arne
More information about the general
mailing list