Peter Malone <peter <at> petermalone.org> writes:
>
> Hi,
>
> Same as the others. Replace malloc & memset with calloc in
usr.sbin/snmpd/mib.c
>
> Index: mib.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/mib.c,v
> retrieving revision 1.67
> diff -u -p -u -r1.67 mib.c
> --- mib.c 8 Apr 2014 14:04:11 -0000 1.67
> +++ mib.c 24 Apr 2014 02:29:26 -0000
> <at> <at> -2818,9 +2818,8 <at> <at> mib_carpifget(u_int idx)
> return (NULL);
> }
>
> - cif = malloc(sizeof(struct carpif));
> + cif = calloc(1, sizeof(struct carpif));
> if (cif != NULL) {
> - memset(cif, 0, sizeof(struct carpif));
> memcpy(&cif->carpr, &carpr, sizeof(struct carpreq));
> memcpy(&cif->kif, kif, sizeof(struct kif));
> }
>
A question:
Wouldn't
cif->carpr = carpr;
cif->kif = *kif;
be more readable?
Or there is some specific reasons not to use
structure assignement?