Fix: use off_t type for lseek function return value to avoid overflow
[lttng-tools.git] / src / common / utils.c
index 004cd8f0d1dcee02aa4b22a4e7f5c6f84a4618f7..7d018b53b1b9430cfb427761f9d4b4a4573e0334 100644 (file)
@@ -1487,15 +1487,17 @@ LTTNG_HIDDEN
 int utils_truncate_stream_file(int fd, off_t length)
 {
        int ret;
+       off_t lseek_ret;
 
        ret = ftruncate(fd, length);
        if (ret < 0) {
                PERROR("ftruncate");
                goto end;
        }
-       ret = lseek(fd, length, SEEK_SET);
-       if (ret < 0) {
+       lseek_ret = lseek(fd, length, SEEK_SET);
+       if (lseek_ret < 0) {
                PERROR("lseek");
+               ret = -1;
                goto end;
        }
 end:
This page took 0.023505 seconds and 4 git commands to generate.