[ofa-general] Issues with _osm_lin_fwd_tbl

Vincent Ficet jean-vincent.ficet at bull.net
Wed Jun 11 07:51:31 PDT 2008


Hi,

The function opensm/osm_lin_fwd_table.c:osm_lin_tbl_new()  invokes 
__osm_lin_tbl_compute_obj_size with a 'size' parameter that is obviously 
a LID (uint16_t). However, the prototype for 
__osm_lin_tbl_compute_obj_size is:

static inline size_t __osm_lin_tbl_compute_obj_size(IN const uint32_t 
num_ports)

Furthermore, the comments in the osm_lin_fwd_tbl_t declaration say:

*    port_tbl
*        The array that specifies the port number which routes the
*        corresponding LID.  Index is by LID.
*

Am I right in saying that the prototype for 
__osm_lin_tbl_compute_obj_size() should be:

static inline size_t __osm_lin_tbl_compute_obj_size(IN const uint16_t 
num_lids)

This would avoid casting its return value as follows in osm_lin_tbl_new():

p_tbl->size = (uint16_t) size;

Also, could anyone explain why the osm_lin_fwd_tbl_t is declared as follows:

typedef struct _osm_lin_fwd_tbl {
    uint16_t size;
    uint8_t port_tbl[1];
} osm_lin_fwd_tbl_t;

This prototype is obviously quite different than the corresponding 
malloc'ed space in  __osm_lin_tbl_compute_obj_size():

return (sizeof(osm_lin_fwd_tbl_t) + (num_ports - 1));

Thanks,

Vincent





More information about the general mailing list