Change-Id: I9cc666191742d041b330e3f9a0b00d743b8f1b92
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
#include "daprobe.h"
-static size_t fsize(int fd)
+static ssize_t fsize(int fd)
{
struct stat st;
if (fstat(fd, &st) != 0)
- return 0;
+ return -1;
return st.st_size;
}
struct file_buffer *file_buffer_create(const char *path)
{
int fd, ret;
+ ssize_t size;
struct file_buffer *fb;
const size_t MAX_FILE_SIZE = 32 * 1024 * 1024;
goto free_fb;
}
- fb->size = fsize(fd);
- if (!fb->size) {
+ size = fsize(fd);
+ if (size < 0) {
PRINTERR("Cannot calculate file size, path='%s'", path);
goto close_fd;
}
+ fb->size = size;
if (fb->size > MAX_FILE_SIZE) {
PRINTERR("File size is very long, size=%zu", fb->size);
goto close_fd;