openCryptoki uses a single list of strings that has all the errors we can print
in it. This is a good thing, in that we don't have multiple copies of the same
string littering memory at run time.
The down-side is the way we use these strings:
st_err_log(14, __FILE__, __LINE__)
What the heck does that log? .... (opens source... find log.c ... counts
numbers... ok, I found it).
Let's replace this with something that's easier to verify while reading the
code. Note that there isn't a 1:1 mapping between the CKR_ return code being
returned and the error string being printed at the time the rc is returned.
This means that using the CKR_ value as an index into the string array won't
work.
How about this:
#define LOG_ERR(string_num) st_err_log(string_num, __FILE__,
__LINE__)
enum {
ERR_MALLOC_FAILED=0,
ERR_NOT_ENOUGH_MEM_IN_CTX,
...
}
So
st_err_log(0, __FILE__, __LINE__);
becomes
LOG_ERR(ERR_MALLOC_FAILED);
This shouldn't increase the size of the binary at all, but is readable and
continues to log everything we currently log. There will be 3 special cases
though, where the string in err_msg[] takes an argument. Let me know what you
think.
Thanks,
Kent
------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Opencryptoki-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech