On Fri, Jun 16, 2006 at 01:36:01PM +0200, Peter Troeger wrote:
The DRMAA specification is intended to be language independent, and hopefully talks always about the length of a string. A string is a collection of printable characters, therefore '\0' should not count. Could it be that you talk here about specifics of the C-binding ("error_diag_len", "job_id_len") ?
Yes, I'm talking mainly about the C-binding, but the specifiaction also adds some words about _BUFFER constants and is sometimes inconsistent as you noted... The constants (and whether they include '\0' or not) is one issue, but I think the most important is what all the _len arguments mean in C-binding. The worst thing that could happen when a developer misunderstands the constants (max len vs. buffer size) is truncation, but a wrong argument in function calls could lead to a crash. From C-binding document: job_id_len - The size in characters of the job identifier buffer. This would clearly mean sizeof(buf), but the "characters" makes me think it could be the maximum number of printable characters that will be put into the buffer. In my opionion this word is not needed here, it should only say "the size of the job identifier buffer". And as for the constants, in my opinion, as they are supposed to be langunage independent, they should mean the max string length... but then, the name preffix _MAXLEN instead of _BUFFER would be better.
String length vs. buffer size would be optimal.
indeed.
I'm more convinced that the constants define the total buffer size, but some DRMAA example source codes got me confused, e.g. they define variables char foo[DRMAA_JOBNAME_BUFFER] but use DRMAA_JOBNAME_BUFFER - 1 as call arguments.
I think it was intended to do it the first way. I propose that the DRMAA spec should say:
"The length of any output context-specific error string SHALL NOT exceed DRMAA_ERROR_STRING_BUFFER - 1."
But doesn't it make the specification language dependent? -- Piotr Domagalski