[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pdf-devel] Confusion about return values
From: |
jemarch |
Subject: |
Re: [pdf-devel] Confusion about return values |
Date: |
Sat, 08 Mar 2008 13:51:28 +0100 |
User-agent: |
Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/23.0.60 (powerpc-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
I'm trying to get the unit tests to pass, and I'm getting failures
in the file stream tests. I'll fix up the code, but I need to
understand what is intended.
pdf_stm_t pdf_create_file_stm (char *filename, int mode)
I take it that this is meant to return a file object, or NULL on
failure.
Right.
The code is wrong, because it checks the return value of the backend init
function against NULL, but the function signature in struct pdf_stm_be_s is
int (*init) (void **be_data, void *conf_data);
and the file backend returns PDF_OK or PDF_ERROR
Is the intent that the backend init() return value is really a
pdf_status_t?
Yes.
If so, why it is the signature an int?
That signature is wrong. It should be:
pdf_status_t (*init) (void **be_data, void *conf_data);
The same for the other backend functions.
Same logic applies for most of the other backend functions. The unit tests
contain checks like:
fail_if (!pdf_stm_close (stm));
which IMHO would be a lot clearer if it checked against PDF_OK.
I agree. Would be much better to write those checks as:
fail_if (pdf_stm_close (stm) != PDF_OK);