projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into connectivity
[collectd.git]
/
src
/
utils_tail.c
diff --git
a/src/utils_tail.c
b/src/utils_tail.c
index
cdab6a7
..
55a3287
100644
(file)
--- a/
src/utils_tail.c
+++ b/
src/utils_tail.c
@@
-43,15
+43,11
@@
struct cu_tail_s {
static int cu_tail_reopen(cu_tail_t *obj) {
int seek_end = 0;
static int cu_tail_reopen(cu_tail_t *obj) {
int seek_end = 0;
- FILE *fh;
struct stat stat_buf = {0};
struct stat stat_buf = {0};
- int status;
- status = stat(obj->file, &stat_buf);
+
int
status = stat(obj->file, &stat_buf);
if (status != 0) {
if (status != 0) {
- char errbuf[1024];
- ERROR("utils_tail: stat (%s) failed: %s", obj->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ P_ERROR("utils_tail: stat (%s) failed: %s", obj->file, STRERRNO);
return -1;
}
return -1;
}
@@
-59,12
+55,10
@@
static int cu_tail_reopen(cu_tail_t *obj) {
if ((obj->fh != NULL) && (stat_buf.st_ino == obj->stat.st_ino)) {
/* Seek to the beginning if file was truncated */
if (stat_buf.st_size < obj->stat.st_size) {
if ((obj->fh != NULL) && (stat_buf.st_ino == obj->stat.st_ino)) {
/* Seek to the beginning if file was truncated */
if (stat_buf.st_size < obj->stat.st_size) {
- INFO("utils_tail: File `%s' was truncated.", obj->file);
+
P_
INFO("utils_tail: File `%s' was truncated.", obj->file);
status = fseek(obj->fh, 0, SEEK_SET);
if (status != 0) {
status = fseek(obj->fh, 0, SEEK_SET);
if (status != 0) {
- char errbuf[1024];
- ERROR("utils_tail: fseek (%s) failed: %s", obj->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ P_ERROR("utils_tail: fseek (%s) failed: %s", obj->file, STRERRNO);
fclose(obj->fh);
obj->fh = NULL;
return -1;
fclose(obj->fh);
obj->fh = NULL;
return -1;
@@
-79,20
+73,16
@@
static int cu_tail_reopen(cu_tail_t *obj) {
if ((obj->stat.st_ino == 0) || (obj->stat.st_ino == stat_buf.st_ino))
seek_end = 1;
if ((obj->stat.st_ino == 0) || (obj->stat.st_ino == stat_buf.st_ino))
seek_end = 1;
- fh = fopen(obj->file, "r");
+
FILE *
fh = fopen(obj->file, "r");
if (fh == NULL) {
if (fh == NULL) {
- char errbuf[1024];
- ERROR("utils_tail: fopen (%s) failed: %s", obj->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ P_ERROR("utils_tail: fopen (%s) failed: %s", obj->file, STRERRNO);
return -1;
}
if (seek_end != 0) {
status = fseek(fh, 0, SEEK_END);
if (status != 0) {
return -1;
}
if (seek_end != 0) {
status = fseek(fh, 0, SEEK_END);
if (status != 0) {
- char errbuf[1024];
- ERROR("utils_tail: fseek (%s) failed: %s", obj->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ P_ERROR("utils_tail: fseek (%s) failed: %s", obj->file, STRERRNO);
fclose(fh);
return -1;
}
fclose(fh);
return -1;
}
@@
-183,9
+173,8
@@
int cu_tail_readline(cu_tail_t *obj, char *buf, int buflen) {
}
if (ferror(obj->fh) != 0) {
}
if (ferror(obj->fh) != 0) {
- char errbuf[1024];
WARNING("utils_tail: fgets (%s) returned an error: %s", obj->file,
WARNING("utils_tail: fgets (%s) returned an error: %s", obj->file,
-
sstrerror(errno, errbuf, sizeof(errbuf))
);
+
STRERRNO
);
fclose(obj->fh);
obj->fh = NULL;
return -1;
fclose(obj->fh);
obj->fh = NULL;
return -1;