On Mon, 23 Aug 2010 14:30:12 -0500
Kent Yoder <[email protected]> wrote:

> 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.

I definitely like that. But if we're touching this, I'd like to make
sure we have a single place for all logging (and possibly tracing)
facilities, and that we're exercising p11util.c for generic pkcs#11
stuff.

To speak frankly, I don't care much about __FUNCTION__, __FILE__ and
__LINE__.. Perhaps we could have a  generic "log_ockerror(errorcode,
message)"? This way we could add location info as well as any other
eventual parameters.

 -Klaus


-- 
Klaus Heinrich Kiwi | [email protected] | http://blog.klauskiwi.com
Open Source Security blog :     http://www.ratliff.net/blog
IBM Linux Technology Center :   http://www.ibm.com/linux/ltc

------------------------------------------------------------------------------
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

Reply via email to