Image load: Change error code on zero file size

From IMLIB_LOAD_ERROR_UNKNOWN to IMLIB_LOAD_ERROR_IMAGE_READ.

Mostly to get the same error from loading a 0 byte file as any other too
short file.
This commit is contained in:
Kim Woelders 2022-03-18 13:36:55 +01:00
parent 7d53ba4e86
commit bf07b104f3
2 changed files with 2 additions and 2 deletions

View File

@ -509,7 +509,7 @@ __imlib_LoadImage(const char *file, ImlibLoadArgs * ila)
else if (__imlib_StatIsDir(&st))
err = IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY;
else if (st.st_size == 0)
err = IMLIB_LOAD_ERROR_UNKNOWN;
err = IMLIB_LOAD_ERROR_IMAGE_READ;
if (err)
{

View File

@ -130,7 +130,7 @@ test_load(void)
D("Load empty '%s'\n", fileo);
im = imlib_load_image_with_error_return(fileo, &lerr);
D(" err = %d\n", lerr);
EXPECT_TRUE(lerr == IMLIB_LOAD_ERROR_UNKNOWN);
EXPECT_EQ(lerr, IMLIB_LOAD_ERROR_IMAGE_READ);
// Non-existing files of all types
snprintf(fileo, sizeof(fileo), "%s/%s.%s", IMG_GEN, "nonex", pfxs[i]);