u3: improves image-related error messages in events

This commit is contained in:
Joe Bryan 2022-08-10 12:14:00 -04:00
parent c9a80338ee
commit 6e9c0033eb

View File

@ -699,7 +699,7 @@ _ce_image_resize(u3e_image* img_u, c3_w pgs_w)
{ {
if ( img_u->pgs_w > pgs_w ) { if ( img_u->pgs_w > pgs_w ) {
if ( ftruncate(img_u->fid_i, pgs_w << (u3a_page + 2)) ) { if ( ftruncate(img_u->fid_i, pgs_w << (u3a_page + 2)) ) {
fprintf(stderr, "loom: image truncate %s: %s\r\n", fprintf(stderr, "loom: image (%s) truncate: %s\r\n",
img_u->nam_c, img_u->nam_c,
strerror(errno)); strerror(errno));
c3_assert(0); c3_assert(0);
@ -785,7 +785,8 @@ _ce_image_blit(u3e_image* img_u,
lseek(img_u->fid_i, 0, SEEK_SET); lseek(img_u->fid_i, 0, SEEK_SET);
for ( i_w = 0; i_w < img_u->pgs_w; i_w++ ) { for ( i_w = 0; i_w < img_u->pgs_w; i_w++ ) {
if ( -1 == read(img_u->fid_i, ptr_w, siz_w) ) { if ( -1 == read(img_u->fid_i, ptr_w, siz_w) ) {
fprintf(stderr, "loom: image blit read: %s\r\n", strerror(errno)); fprintf(stderr, "loom: image (%s) blit read: %s\r\n",
img_u->nam_c, strerror(errno));
c3_assert(0); c3_assert(0);
} }
@ -819,7 +820,9 @@ _ce_image_fine(u3e_image* img_u,
c3_w mem_w, fil_w; c3_w mem_w, fil_w;
if ( -1 == read(img_u->fid_i, buf_w, pag_siz_i) ) { if ( -1 == read(img_u->fid_i, buf_w, pag_siz_i) ) {
fprintf(stderr, "loom: image fine read: %s\r\n", strerror(errno)); fprintf(stderr, "loom: image (%s) fine read: %s\r\n",
img_u->nam_c,
strerror(errno));
c3_assert(0); c3_assert(0);
} }
mem_w = u3r_mug_words(ptr_w, pag_wiz_i); mem_w = u3r_mug_words(ptr_w, pag_wiz_i);
@ -828,11 +831,13 @@ _ce_image_fine(u3e_image* img_u,
if ( mem_w != fil_w ) { if ( mem_w != fil_w ) {
c3_w pag_w = (ptr_w - u3_Loom) >> u3a_page; c3_w pag_w = (ptr_w - u3_Loom) >> u3a_page;
fprintf(stderr, "mismatch: page %d, mem_w %x, fil_w %x, K %x\r\n", fprintf(stderr, "loom: image (%s) mismatch: "
pag_w, "page %d, mem_w %x, fil_w %x, K %x\r\n",
mem_w, img_u->nam_c,
fil_w, pag_w,
u3K.mug_w[pag_w]); mem_w,
fil_w,
u3K.mug_w[pag_w]);
abort(); abort();
} }
ptr_w += stp_ws; ptr_w += stp_ws;
@ -856,7 +861,9 @@ _ce_image_copy(u3e_image* fom_u, u3e_image* tou_u)
if ( (-1 == lseek(fom_u->fid_i, 0, SEEK_SET)) if ( (-1 == lseek(fom_u->fid_i, 0, SEEK_SET))
|| (-1 == lseek(tou_u->fid_i, 0, SEEK_SET)) ) || (-1 == lseek(tou_u->fid_i, 0, SEEK_SET)) )
{ {
fprintf(stderr, "loom: image copy seek 0: %s\r\n", strerror(errno)); fprintf(stderr, "loom: image (%s) copy seek: %s\r\n",
fom_u->nam_c,
strerror(errno));
return c3n; return c3n;
} }
@ -867,16 +874,22 @@ _ce_image_copy(u3e_image* fom_u, u3e_image* tou_u)
c3_w off_w = i_w; c3_w off_w = i_w;
if ( -1 == read(fom_u->fid_i, mem_w, pag_siz_i) ) { if ( -1 == read(fom_u->fid_i, mem_w, pag_siz_i) ) {
fprintf(stderr, "loom: image copy read: %s\r\n", strerror(errno)); fprintf(stderr, "loom: image (%s) copy read: %s\r\n",
fom_u->nam_c,
strerror(errno));
return c3n; return c3n;
} }
else { else {
if ( -1 == lseek(tou_u->fid_i, (off_w << (u3a_page + 2)), SEEK_SET) ) { if ( -1 == lseek(tou_u->fid_i, (off_w << (u3a_page + 2)), SEEK_SET) ) {
fprintf(stderr, "loom: image copy seek: %s\r\n", strerror(errno)); fprintf(stderr, "loom: image (%s) copy seek: %s\r\n",
tou_u->nam_c,
strerror(errno));
return c3n; return c3n;
} }
if ( -1 == write(tou_u->fid_i, mem_w, pag_siz_i) ) { if ( -1 == write(tou_u->fid_i, mem_w, pag_siz_i) ) {
fprintf(stderr, "loom: image copy write: %s\r\n", strerror(errno)); fprintf(stderr, "loom: image (%s) copy write: %s\r\n",
tou_u->nam_c,
strerror(errno));
return c3n; return c3n;
} }
} }