Philippe Gerum wrote:
>> -    head = snprintf(name, XNOBJECT_NAME_LEN, "IRQ%d: ", irq);
>> -    name += head;
>> -    strncpy(name, intr->name, XNOBJECT_NAME_LEN-head);
>> +    head = snprintf(name_buf, XNOBJECT_NAME_LEN, "IRQ%d: ", irq);
>> +    strncpy(name_buf + head, intr->name, XNOBJECT_NAME_LEN-head);
> 
> -     strncpy(name_buf + head, intr->name, XNOBJECT_NAME_LEN-head);
> +     strncpy(name_buf + head, intr->name, XNOBJECT_NAME_LEN-1-head);
> +     name_buf[XNOBJECT_NAME_LEN-1] = '\0';
> 
> Object names should always be null-terminated.

Yes, and what is the point of not doing everything with only one
snprintf ? strncpy uselessly burns CPU cycles by filling the destination
buffers with zeros if source is smaller than destination.

-- 
                                                 Gilles.

_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to