*/
#define _LGPL_SOURCE
-#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
DBG("Adding context to channel %s", chan->channel->name);
ret = kernctl_add_context(chan->fd, &ctx->ctx);
if (ret < 0) {
- switch (errno) {
+ switch (-ret) {
case ENOSYS:
/* Exists but not available for this kernel */
ret = LTTNG_ERR_KERN_CONTEXT_UNAVAILABLE;
ret = kernctl_create_event(channel->fd, event->event);
if (ret < 0) {
- switch (errno) {
+ switch (-ret) {
case EEXIST:
break;
case ENOSYS:
default:
PERROR("create event ioctl");
}
- ret = -errno;
goto free_event;
}
ret = kernctl_enable(event->fd);
if (ret < 0) {
- switch (errno) {
+ switch (-ret) {
case EEXIST:
ret = LTTNG_ERR_KERN_EVENT_EXIST;
break;
ret = kernctl_disable(chan->fd);
if (ret < 0) {
PERROR("disable chan ioctl");
- ret = errno;
goto error;
}
assert(chan);
ret = kernctl_enable(chan->fd);
- if (ret < 0 && errno != EEXIST) {
+ if (ret < 0 && ret != -EEXIST) {
PERROR("Enable kernel chan");
goto error;
}
ret = kernctl_enable(event->fd);
if (ret < 0) {
- switch (errno) {
+ switch (-ret) {
case EEXIST:
ret = LTTNG_ERR_KERN_EVENT_EXIST;
break;
ret = kernctl_disable(event->fd);
if (ret < 0) {
- switch (errno) {
+ switch (-ret) {
case EEXIST:
ret = LTTNG_ERR_KERN_EVENT_EXIST;
break;
if (!ret) {
return LTTNG_OK;
}
- switch (errno) {
+ switch (-ret) {
case EINVAL:
return LTTNG_ERR_INVALID;
case ENOMEM:
if (!ret) {
return LTTNG_OK;
}
- switch (errno) {
+ switch (-ret) {
case EINVAL:
return LTTNG_ERR_INVALID;
case ENOMEM:
ret = kernctl_snapshot(infd);
if (ret != 0) {
PERROR("Getting sub-buffer snapshot.");
- ret = -errno;
}
return ret;
ret = kernctl_snapshot_get_produced(infd, pos);
if (ret != 0) {
PERROR("kernctl_snapshot_get_produced");
- ret = -errno;
}
return ret;
ret = kernctl_snapshot_get_consumed(infd, pos);
if (ret != 0) {
PERROR("kernctl_snapshot_get_consumed");
- ret = -errno;
}
return ret;
ret = kernctl_buffer_flush(stream->wait_fd);
if (ret < 0) {
ERR("Failed to flush kernel stream");
- ret = -errno;
goto end_unlock;
}
&stream->max_sb_size);
if (ret < 0) {
ERR("Getting kernel max_sb_size");
- ret = -errno;
goto end_unlock;
}
}
ret = kernctl_get_subbuf(stream->wait_fd, &consumed_pos);
if (ret < 0) {
- if (errno != EAGAIN) {
+ if (ret != -EAGAIN) {
PERROR("kernctl_get_subbuf snapshot");
- ret = -errno;
goto end_unlock;
}
DBG("Kernel consumer get subbuf failed. Skipping it.");
ret = kernctl_get_subbuf_size(stream->wait_fd, &len);
if (ret < 0) {
ERR("Snapshot kernctl_get_subbuf_size");
- ret = -errno;
goto error_put_subbuf;
}
ret = kernctl_get_padded_subbuf_size(stream->wait_fd, &padded_len);
if (ret < 0) {
ERR("Snapshot kernctl_get_padded_subbuf_size");
- ret = -errno;
goto error_put_subbuf;
}
ret = kernctl_put_subbuf(stream->wait_fd);
if (ret < 0) {
ERR("Snapshot kernctl_put_subbuf");
- ret = -errno;
goto end_unlock;
}
consumed_pos += stream->max_sb_size;
error_put_subbuf:
ret = kernctl_put_subbuf(stream->wait_fd);
if (ret < 0) {
- ret = -errno;
ERR("Snapshot kernctl_put_subbuf error path");
}
end_unlock:
ret = kernctl_snapshot(metadata->wait_fd);
if (ret < 0) {
- if (errno != EAGAIN) {
+ if (ret != -EAGAIN) {
ERR("Sync metadata, taking kernel snapshot failed.");
goto end;
}
*/
DBG("Reserving sub buffer failed (everything is normal, "
"it is due to concurrency)");
- ret = -errno;
+ ret = err;
goto end;
}
PERROR("Getting sub-buffer len failed.");
err = kernctl_put_subbuf(infd);
if (err != 0) {
- if (errno == EFAULT) {
+ if (err == -EFAULT) {
PERROR("Error in unreserving sub buffer\n");
- } else if (errno == EIO) {
+ } else if (err == -EIO) {
/* Should never happen with newer LTTng versions */
PERROR("Reader has been pushed by the writer, last sub-buffer corrupted.");
}
- ret = -errno;
+ ret = err;
goto end;
}
- ret = -errno;
+ ret = err;
goto end;
}
if (ret < 0) {
err = kernctl_put_subbuf(infd);
if (err != 0) {
- if (errno == EFAULT) {
+ if (err == -EFAULT) {
PERROR("Error in unreserving sub buffer\n");
- } else if (errno == EIO) {
+ } else if (err == -EIO) {
/* Should never happen with newer LTTng versions */
PERROR("Reader has been pushed by the writer, last sub-buffer corrupted.");
}
- ret = -errno;
+ ret = err;
goto end;
}
goto end;
PERROR("Getting sub-buffer len failed.");
err = kernctl_put_subbuf(infd);
if (err != 0) {
- if (errno == EFAULT) {
+ if (err == -EFAULT) {
PERROR("Error in unreserving sub buffer\n");
- } else if (errno == EIO) {
+ } else if (err == -EIO) {
/* Should never happen with newer LTTng versions */
PERROR("Reader has been pushed by the writer, last sub-buffer corrupted.");
}
- ret = -errno;
+ ret = err;
goto end;
}
- ret = -errno;
+ ret = err;
goto end;
}
err = kernctl_put_next_subbuf(infd);
if (err != 0) {
- if (errno == EFAULT) {
+ if (err == -EFAULT) {
PERROR("Error in unreserving sub buffer\n");
- } else if (errno == EIO) {
+ } else if (err == -EIO) {
/* Should never happen with newer LTTng versions */
PERROR("Reader has been pushed by the writer, last sub-buffer corrupted.");
}
- ret = -errno;
+ ret = err;
goto end;
}
ret = kernctl_get_mmap_len(stream->wait_fd, &mmap_len);
if (ret != 0) {
PERROR("kernctl_get_mmap_len");
- ret = -errno;
goto error_close_fd;
}
stream->mmap_len = (size_t) mmap_len;