Skip to content

Commit

Permalink
lib/raster: add strerror(errno) to write failures (#1722)
Browse files Browse the repository at this point in the history
  • Loading branch information
metzm committed Jul 12, 2021
1 parent 1728434 commit 8dba744
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/raster/put_row.c
Expand Up @@ -388,14 +388,14 @@ static void put_data(int fd, char *null_buf, const CELL * cell,
nwrite++;

if (write(fcb->data_fd, compressed_buf, nwrite) != nwrite)
G_fatal_error(_("Error writing compressed data for row %d of <%s>"),
row, fcb->name);
G_fatal_error(_("Error writing compressed data for row %d of <%s>: %s"),
row, fcb->name, strerror(errno));
}
else {
nwrite = nbytes * n + 1;
if (write(fcb->data_fd, work_buf, nwrite) != nwrite)
G_fatal_error(_("Error writing compressed data for row %d of <%s>"),
row, fcb->name);
G_fatal_error(_("Error writing compressed data for row %d of <%s>: %s"),
row, fcb->name, strerror(errno));
}

G_free(compressed_buf);
Expand All @@ -404,8 +404,8 @@ static void put_data(int fd, char *null_buf, const CELL * cell,
nwrite = fcb->nbytes * n;

if (write(fcb->data_fd, work_buf, nwrite) != nwrite)
G_fatal_error(_("Error writing uncompressed data for row %d of <%s>"),
row, fcb->name);
G_fatal_error(_("Error writing uncompressed data for row %d of <%s>: %s"),
row, fcb->name, strerror(errno));
}

G_free(work_buf);
Expand Down Expand Up @@ -518,13 +518,13 @@ static void write_null_bits_compressed(const unsigned char *flags,

if (nwrite > 0 && nwrite < size) {
if (write(fcb->null_fd, compressed_buf, nwrite) != nwrite)
G_fatal_error(_("Error writing compressed null data for row %d of <%s>"),
row, fcb->name);
G_fatal_error(_("Error writing compressed null data for row %d of <%s>: %s"),
row, fcb->name, strerror(errno));
}
else {
if (write(fcb->null_fd, flags, size) != size)
G_fatal_error(_("Error writing compressed null data for row %d of <%s>"),
row, fcb->name);
G_fatal_error(_("Error writing compressed null data for row %d of <%s>: %s"),
row, fcb->name, strerror(errno));
}

G_free(compressed_buf);
Expand Down Expand Up @@ -557,10 +557,12 @@ void Rast__write_null_bits(int fd, const unsigned char *flags)
offset = (off_t) size * row;

if (lseek(fcb->null_fd, offset, SEEK_SET) < 0)
G_fatal_error(_("Error writing null row %d of <%s>"), row, fcb->name);
G_fatal_error(_("Error writing null row %d of <%s>"),
row, fcb->name);

if (write(fcb->null_fd, flags, size) != size)
G_fatal_error(_("Error writing null row %d of <%s>"), row, fcb->name);
G_fatal_error(_("Error writing null row %d of <%s>: %s"),
row, fcb->name, strerror(errno));
}

static void convert_and_write_if(int fd, const void *vbuf)
Expand Down

0 comments on commit 8dba744

Please sign in to comment.