[ofa-general] ***SPAM*** Re: [PATCHv2] opensm/osm_helper.c: Add more info for traps 144 and 256-259 in osm_dump_notice

Sasha Khapyorsky sashak at voltaire.com
Tue Apr 14 07:09:31 PDT 2009


On 09:42 Tue 14 Apr     , Hal Rosenstock wrote:
> 
> Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
> 
> ---
> Changes from v1:
> In trap 144, display local changes as %u rather than %d
> In trap 256, don't use additional buffer and eliminate buffer copying
> 
> diff --git a/opensm/opensm/osm_helper.c b/opensm/opensm/osm_helper.c

[snip...]

> +				n += sprintf(buff + n, "Directed Path Dump of %u hop path:"
> +					"\n\t\t\t\tPath = ",
> +					p_ntci->data_details.ntc_256.dr_trunc_hop & 0x3f);
> +				for (i = 0;
> +				     i <= (p_ntci->data_details.ntc_256.dr_trunc_hop & 0x3f);
> +				     i++) {
> +					if (i == 0)
> +						sprintf(buff + n, "%d",
> +							p_ntci->data_details.ntc_256.dr_rtn_path[i]);
> +					else
> +						sprintf(buff + n, ",%d",
> +							p_ntci->data_details.ntc_256.dr_rtn_path[i]);

Should be n += sprintf() in both cases. Also I would recommend to use
snprintf() instead of sprintf() to prevent possible buf overflow.

Sasha



More information about the general mailing list