From: Mathieu Desnoyers Date: Fri, 2 Mar 2012 18:03:38 +0000 (-0500) Subject: Fix: All perror turned into PERROR to show file and line number X-Git-Tag: v2.0.0-rc2~11 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=df0f840ba686e3fe670c9906fd46330fff65da07;p=lttng-tools.git Fix: All perror turned into PERROR to show file and line number Needed to find error culprits. Signed-off-by: Mathieu Desnoyers --- diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 2936406d8..0922c3d49 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -42,7 +42,7 @@ int kernel_add_channel_context(struct ltt_kernel_channel *chan, ret = kernctl_add_context(chan->fd, ctx); if (ret < 0) { if (errno != EEXIST) { - perror("add context ioctl"); + PERROR("add context ioctl"); } else { /* If EEXIST, we just ignore the error */ ret = 0; @@ -52,7 +52,7 @@ int kernel_add_channel_context(struct ltt_kernel_channel *chan, chan->ctx = zmalloc(sizeof(struct lttng_kernel_context)); if (chan->ctx == NULL) { - perror("zmalloc event context"); + PERROR("zmalloc event context"); goto error; } @@ -75,13 +75,13 @@ int kernel_add_event_context(struct ltt_kernel_event *event, DBG("Adding context to event %s", event->event->name); ret = kernctl_add_context(event->fd, ctx); if (ret < 0) { - perror("add context ioctl"); + PERROR("add context ioctl"); goto error; } event->ctx = zmalloc(sizeof(struct lttng_kernel_context)); if (event->ctx == NULL) { - perror("zmalloc event context"); + PERROR("zmalloc event context"); goto error; } @@ -112,7 +112,7 @@ int kernel_create_session(struct ltt_session *session, int tracer_fd) /* Kernel tracer session creation */ ret = kernctl_create_session(tracer_fd); if (ret < 0) { - perror("ioctl kernel create session"); + PERROR("ioctl kernel create session"); goto error; } @@ -120,7 +120,7 @@ int kernel_create_session(struct ltt_session *session, int tracer_fd) /* Prevent fd duplication after execlp() */ ret = fcntl(lks->fd, F_SETFD, FD_CLOEXEC); if (ret < 0) { - perror("fcntl session fd"); + PERROR("fcntl session fd"); } lks->consumer_fds_sent = 0; @@ -153,7 +153,7 @@ int kernel_create_channel(struct ltt_kernel_session *session, /* Kernel tracer channel creation */ ret = kernctl_create_channel(session->fd, &lkc->channel->attr); if (ret < 0) { - perror("ioctl kernel create channel"); + PERROR("ioctl kernel create channel"); goto error; } @@ -162,7 +162,7 @@ int kernel_create_channel(struct ltt_kernel_session *session, /* Prevent fd duplication after execlp() */ ret = fcntl(lkc->fd, F_SETFD, FD_CLOEXEC); if (ret < 0) { - perror("fcntl session fd"); + PERROR("fcntl session fd"); } /* Add channel to session */ @@ -220,7 +220,7 @@ int kernel_create_event(struct lttng_event *ev, /* Prevent fd duplication after execlp() */ ret = fcntl(event->fd, F_SETFD, FD_CLOEXEC); if (ret < 0) { - perror("fcntl session fd"); + PERROR("fcntl session fd"); } add_list: @@ -247,7 +247,7 @@ int kernel_disable_channel(struct ltt_kernel_channel *chan) ret = kernctl_disable(chan->fd); if (ret < 0) { - perror("disable chan ioctl"); + PERROR("disable chan ioctl"); ret = errno; goto error; } @@ -270,7 +270,7 @@ int kernel_enable_channel(struct ltt_kernel_channel *chan) ret = kernctl_enable(chan->fd); if (ret < 0 && errno != EEXIST) { - perror("Enable kernel chan"); + PERROR("Enable kernel chan"); goto error; } @@ -292,7 +292,7 @@ int kernel_enable_event(struct ltt_kernel_event *event) ret = kernctl_enable(event->fd); if (ret < 0 && errno != EEXIST) { - perror("enable kernel event"); + PERROR("enable kernel event"); goto error; } @@ -314,7 +314,7 @@ int kernel_disable_event(struct ltt_kernel_event *event) ret = kernctl_disable(event->fd); if (ret < 0 && errno != EEXIST) { - perror("disable kernel event"); + PERROR("disable kernel event"); goto error; } @@ -352,7 +352,7 @@ int kernel_open_metadata(struct ltt_kernel_session *session, char *path) /* Prevent fd duplication after execlp() */ ret = fcntl(lkm->fd, F_SETFD, FD_CLOEXEC); if (ret < 0) { - perror("fcntl session fd"); + PERROR("fcntl session fd"); } session->metadata = lkm; @@ -374,7 +374,7 @@ int kernel_start_session(struct ltt_kernel_session *session) ret = kernctl_start_session(session->fd); if (ret < 0) { - perror("ioctl start session"); + PERROR("ioctl start session"); goto error; } @@ -397,7 +397,7 @@ void kernel_wait_quiescent(int fd) ret = kernctl_wait_quiescent(fd); if (ret < 0) { - perror("wait quiescent ioctl"); + PERROR("wait quiescent ioctl"); ERR("Kernel quiescent wait failed"); } } @@ -411,7 +411,7 @@ int kernel_calibrate(int fd, struct lttng_kernel_calibrate *calibrate) ret = kernctl_calibrate(fd, calibrate); if (ret < 0) { - perror("calibrate ioctl"); + PERROR("calibrate ioctl"); return -1; } @@ -448,7 +448,7 @@ int kernel_flush_buffer(struct ltt_kernel_channel *channel) DBG("Flushing channel stream %d", stream->fd); ret = kernctl_buffer_flush(stream->fd); if (ret < 0) { - perror("ioctl"); + PERROR("ioctl"); ERR("Fail to flush buffer for stream %d (ret: %d)", stream->fd, ret); } @@ -499,13 +499,13 @@ int kernel_open_channel_stream(struct ltt_kernel_channel *channel) /* Prevent fd duplication after execlp() */ ret = fcntl(lks->fd, F_SETFD, FD_CLOEXEC); if (ret < 0) { - perror("fcntl session fd"); + PERROR("fcntl session fd"); } ret = asprintf(&lks->pathname, "%s/%s_%d", channel->pathname, channel->channel->name, channel->stream_count); if (ret < 0) { - perror("asprintf kernel create stream"); + PERROR("asprintf kernel create stream"); goto error; } @@ -532,7 +532,7 @@ int kernel_open_metadata_stream(struct ltt_kernel_session *session) ret = kernctl_create_stream(session->metadata->fd); if (ret < 0) { - perror("kernel create metadata stream"); + PERROR("kernel create metadata stream"); goto error; } @@ -541,7 +541,7 @@ int kernel_open_metadata_stream(struct ltt_kernel_session *session) /* Prevent fd duplication after execlp() */ ret = fcntl(session->metadata_stream_fd, F_SETFD, FD_CLOEXEC); if (ret < 0) { - perror("fcntl session fd"); + PERROR("fcntl session fd"); } return 0; @@ -564,13 +564,13 @@ ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events) fd = kernctl_tracepoint_list(tracer_fd); if (fd < 0) { - perror("kernel tracepoint list"); + PERROR("kernel tracepoint list"); goto error; } fp = fdopen(fd, "r"); if (fp == NULL) { - perror("kernel tracepoint list fdopen"); + PERROR("kernel tracepoint list fdopen"); goto error_fp; } @@ -589,7 +589,7 @@ ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events) nbmem <<= 1; elist = realloc(elist, nbmem * sizeof(struct lttng_event)); if (elist == NULL) { - perror("realloc list events"); + PERROR("realloc list events"); count = -ENOMEM; goto end; } diff --git a/src/bin/lttng-sessiond/modprobe.c b/src/bin/lttng-sessiond/modprobe.c index a87d70754..65032e414 100644 --- a/src/bin/lttng-sessiond/modprobe.c +++ b/src/bin/lttng-sessiond/modprobe.c @@ -101,7 +101,7 @@ void modprobe_remove_lttng_data(void) "/sbin/modprobe -r -q %s", kern_modules_list[i].name); if (ret < 0) { - perror("snprintf modprobe -r"); + PERROR("snprintf modprobe -r"); goto error; } modprobe[sizeof(modprobe) - 1] = '\0'; @@ -182,7 +182,7 @@ int modprobe_lttng_data(void) kern_modules_list[i].required ? "" : "-q ", kern_modules_list[i].name); if (ret < 0) { - perror("snprintf modprobe"); + PERROR("snprintf modprobe"); goto error; } modprobe[sizeof(modprobe) - 1] = '\0'; diff --git a/src/bin/lttng-sessiond/session.c b/src/bin/lttng-sessiond/session.c index e890d07ba..e7fc7c35a 100644 --- a/src/bin/lttng-sessiond/session.c +++ b/src/bin/lttng-sessiond/session.c @@ -177,7 +177,7 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid) /* Allocate session data structure */ new_session = zmalloc(sizeof(struct ltt_session)); if (new_session == NULL) { - perror("zmalloc"); + PERROR("zmalloc"); ret = LTTCOMM_FATAL; goto error_malloc; } diff --git a/src/bin/lttng-sessiond/shm.c b/src/bin/lttng-sessiond/shm.c index 77c09995c..ce1844fe8 100644 --- a/src/bin/lttng-sessiond/shm.c +++ b/src/bin/lttng-sessiond/shm.c @@ -51,7 +51,7 @@ static int get_wait_shm(char *shm_path, size_t mmap_size, int global) ret = chown(shm_path, 0, 0); if (ret < 0) { if (errno != ENOENT) { - perror("chown wait shm"); + PERROR("chown wait shm"); goto error; } } @@ -65,7 +65,7 @@ static int get_wait_shm(char *shm_path, size_t mmap_size, int global) ret = chown(shm_path, getuid(), getgid()); if (ret < 0) { if (errno != ENOENT) { - perror("chown wait shm"); + PERROR("chown wait shm"); goto error; } } @@ -77,7 +77,7 @@ static int get_wait_shm(char *shm_path, size_t mmap_size, int global) ret = chmod(shm_path, mode); if (ret < 0) { if (errno != ENOENT) { - perror("chmod wait shm"); + PERROR("chmod wait shm"); goto error; } } @@ -94,19 +94,19 @@ static int get_wait_shm(char *shm_path, size_t mmap_size, int global) */ wait_shm_fd = shm_open(shm_path, O_RDWR | O_CREAT, mode); if (wait_shm_fd < 0) { - perror("shm_open wait shm"); + PERROR("shm_open wait shm"); goto error; } ret = ftruncate(wait_shm_fd, mmap_size); if (ret < 0) { - perror("ftruncate wait shm"); + PERROR("ftruncate wait shm"); exit(EXIT_FAILURE); } ret = fchmod(wait_shm_fd, mode); if (ret < 0) { - perror("fchmod"); + PERROR("fchmod"); exit(EXIT_FAILURE); } @@ -145,7 +145,7 @@ char *shm_ust_get_mmap(char *shm_path, int global) /* close shm fd immediately after taking the mmap reference */ ret = close(wait_shm_fd); if (ret) { - perror("Error closing fd"); + PERROR("Error closing fd"); } if (wait_shm_mmap == MAP_FAILED) { diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 68753286f..0116e84a0 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -91,7 +91,7 @@ struct ltt_kernel_session *trace_kernel_create_session(char *path) /* Allocate a new ltt kernel session */ lks = zmalloc(sizeof(struct ltt_kernel_session)); if (lks == NULL) { - perror("create kernel session zmalloc"); + PERROR("create kernel session zmalloc"); goto error; } @@ -107,7 +107,7 @@ struct ltt_kernel_session *trace_kernel_create_session(char *path) /* Set session path */ ret = asprintf(&lks->trace_path, "%s/kernel", path); if (ret < 0) { - perror("asprintf kernel traces path"); + PERROR("asprintf kernel traces path"); goto error; } @@ -129,13 +129,13 @@ struct ltt_kernel_channel *trace_kernel_create_channel(struct lttng_channel *cha lkc = zmalloc(sizeof(struct ltt_kernel_channel)); if (lkc == NULL) { - perror("ltt_kernel_channel zmalloc"); + PERROR("ltt_kernel_channel zmalloc"); goto error; } lkc->channel = zmalloc(sizeof(struct lttng_channel)); if (lkc->channel == NULL) { - perror("lttng_channel zmalloc"); + PERROR("lttng_channel zmalloc"); goto error; } memcpy(lkc->channel, chan, sizeof(struct lttng_channel)); @@ -151,7 +151,7 @@ struct ltt_kernel_channel *trace_kernel_create_channel(struct lttng_channel *cha /* Set default trace output path */ ret = asprintf(&lkc->pathname, "%s", path); if (ret < 0) { - perror("asprintf kernel create channel"); + PERROR("asprintf kernel create channel"); goto error; } @@ -174,7 +174,7 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev) lke = zmalloc(sizeof(struct ltt_kernel_event)); attr = zmalloc(sizeof(struct lttng_kernel_event)); if (lke == NULL || attr == NULL) { - perror("kernel event zmalloc"); + PERROR("kernel event zmalloc"); goto error; } @@ -246,7 +246,7 @@ struct ltt_kernel_metadata *trace_kernel_create_metadata(char *path) lkm = zmalloc(sizeof(struct ltt_kernel_metadata)); chan = zmalloc(sizeof(struct lttng_channel)); if (lkm == NULL || chan == NULL) { - perror("kernel metadata zmalloc"); + PERROR("kernel metadata zmalloc"); goto error; } @@ -264,7 +264,7 @@ struct ltt_kernel_metadata *trace_kernel_create_metadata(char *path) /* Set default metadata path */ ret = asprintf(&lkm->pathname, "%s/metadata", path); if (ret < 0) { - perror("asprintf kernel metadata"); + PERROR("asprintf kernel metadata"); goto error; } @@ -286,7 +286,7 @@ struct ltt_kernel_stream *trace_kernel_create_stream(void) lks = zmalloc(sizeof(struct ltt_kernel_stream)); if (lks == NULL) { - perror("kernel stream zmalloc"); + PERROR("kernel stream zmalloc"); goto error; } diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 55e73930a..9c7cfb690 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -139,7 +139,7 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, luc = zmalloc(sizeof(struct ltt_ust_channel)); if (luc == NULL) { - perror("ltt_ust_channel zmalloc"); + PERROR("ltt_ust_channel zmalloc"); goto error; } @@ -171,7 +171,7 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, /* Set trace output path */ ret = snprintf(luc->pathname, PATH_MAX, "%s", path); if (ret < 0) { - perror("asprintf ust create channel"); + PERROR("asprintf ust create channel"); goto error_free_channel; } @@ -270,7 +270,7 @@ struct ltt_ust_metadata *trace_ust_create_metadata(char *path) lum = zmalloc(sizeof(struct ltt_ust_metadata)); if (lum == NULL) { - perror("ust metadata zmalloc"); + PERROR("ust metadata zmalloc"); goto error; } @@ -286,7 +286,7 @@ struct ltt_ust_metadata *trace_ust_create_metadata(char *path) /* Set metadata trace path */ ret = snprintf(lum->pathname, PATH_MAX, "%s/metadata", path); if (ret < 0) { - perror("asprintf ust metadata"); + PERROR("asprintf ust metadata"); goto error_free_metadata; } diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index d758c8821..ee54e7985 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -58,13 +58,13 @@ static int send_channel_streams(int sock, DBG("Sending channel %d to consumer", lum.u.channel.channel_key); ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum)); if (ret < 0) { - perror("send consumer channel"); + PERROR("send consumer channel"); goto error; } fd = uchan->obj->shm_fd; ret = lttcomm_send_fds_unix_sock(sock, &fd, 1); if (ret < 0) { - perror("send consumer channel ancillary data"); + PERROR("send consumer channel ancillary data"); goto error; } @@ -91,7 +91,7 @@ static int send_channel_streams(int sock, DBG("Sending stream %d to consumer", lum.u.stream.stream_key); ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum)); if (ret < 0) { - perror("send consumer stream"); + PERROR("send consumer stream"); goto error; } @@ -99,7 +99,7 @@ static int send_channel_streams(int sock, fds[1] = stream->obj->wait_fd; ret = lttcomm_send_fds_unix_sock(sock, fds, 2); if (ret < 0) { - perror("send consumer stream ancillary data"); + PERROR("send consumer stream ancillary data"); goto error; } } @@ -142,13 +142,13 @@ int ust_consumer_send_session(int consumer_fd, struct ust_app_session *usess) DBG("Sending metadata channel %d to consumer", lum.u.channel.channel_key); ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum)); if (ret < 0) { - perror("send consumer channel"); + PERROR("send consumer channel"); goto error; } fd = usess->metadata->obj->shm_fd; ret = lttcomm_send_fds_unix_sock(sock, &fd, 1); if (ret < 0) { - perror("send consumer metadata channel"); + PERROR("send consumer metadata channel"); goto error; } @@ -166,14 +166,14 @@ int ust_consumer_send_session(int consumer_fd, struct ust_app_session *usess) DBG("Sending metadata stream %d to consumer", lum.u.stream.stream_key); ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum)); if (ret < 0) { - perror("send consumer metadata stream"); + PERROR("send consumer metadata stream"); goto error; } fds[0] = usess->metadata->stream_obj->shm_fd; fds[1] = usess->metadata->stream_obj->wait_fd; ret = lttcomm_send_fds_unix_sock(sock, fds, 2); if (ret < 0) { - perror("send consumer stream"); + PERROR("send consumer stream"); goto error; } }