[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Freeipmi-devel] Re: My plans

From: Anand Babu
Subject: [Freeipmi-devel] Re: My plans
Date: Tue, 20 Jan 2004 18:42:25 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

,----[ Anand Babu <address@hidden> ]
| ,----[ Albert Chu <address@hidden> ]
| | 2) Almost all the functions take a "fiid_obj_t obj_hdr" or similar
| | parameter, but no "obj_hdr_len" or similar parameter.  Is the buffer
| | length checked at any point internally in the fiid code base?  If not,
| | I am really against having an API like this.  I talked to others here,
| | and having a function that doesn't pass in a buffer length (or hide a
| | buffer length internally within the abstract type) is destined for
| | bugs and problems.
| `----
| In my original code, I passed length arguments. But I changed the
| framework on purpose. Here are my explanations.
| Though it fiid_obj_t is a typedef'd  byte array. libfreeipmi treats
| this as a special object (data-type). 
| 1. All fiid_obj_t must have a template associated
| 2. User should always use fiid_obj_alloc(associated template) to
| create these objects.
| 3. fiid_obj_t is no replacement for all u_int8_t *. Means use it only
| in place of template instantiation.
| 4. fiid_* calls will fetch, all required properties like length, field
| definitions, ... from the associated template. (thats why you see no
| length argument)
| 5. Because fiid_obj_t is a special data-type, no function should
| attempt to manipulate the data directly except fiid_* APIs.
Here is a better explanation.

1) Imagine fiid_obj_t like struct. Like you do sizeof(struct name), here
you fiid_obj_len (template).
2) Also I am having plans to re-define fiid_obj_t in future.

typedef struct fiid_obj
    u_int8_t templ_name[FIID_TEMPL_MAX];
    u_int64_t len;
    u_int8_t *data; /* pointer to byte-array data */

fiid_obj_alloc will instantiate this object properly. This model
avoids carrying template name across functions and re-calculation of
len multiple times.

Free as in Freedom <>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]