Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx> --- common/state/backend_bucket_direct.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c index 152431214..95ddb9310 100644 --- a/common/state/backend_bucket_direct.c +++ b/common/state/backend_bucket_direct.c @@ -113,10 +113,9 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket if (len > direct->max_size - sizeof(meta)) return -E2BIG; - ret = lseek(direct->fd, direct->offset, SEEK_SET); - if (ret < 0) { - dev_err(direct->dev, "Failed to seek file, %d\n", ret); - return ret; + if (lseek(direct->fd, direct->offset, SEEK_SET) != direct->offset) { + dev_err(direct->dev, "Failed to seek file, %d\n", -errno); + return -errno; } /* write the meta data only if there is head room */ -- 2.20.1 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox