Re: about modifying files generated by mib2c

"Dave Shield" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
On 26/07/06, 蔷<Qiang Hu> <[email protected]> wrote:
> unsigned char  *
> var_jmtest(...)
>  {
>     static long     long_ret;
>     int   VAR;

>     switch (vp->magic) {
>     case FIRSTKEY:
>         *write_method = write_firstKey;
>         VAR = 1;            /* XXX */
>   *var_len =sizeof(VAR);
>         return (u_char *) & VAR;


Two comments.
a)  "VAR" *must* be declared as "static", if you are going to return a
reference to it, which will then be accessed by external code.   This
is probably why you are getting different results each time.

b)  The old API (and probably the new one too), expects to use 'long'
variables for integer values.  Why not just use the 'long_ret'
variable that has already been declared for you?
It *might* not matter if you use int instead, but I wouldn't like to
make any promises.
I'd suggest you play safe and use 'long_ret'.

Dave

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.