projects
/
ust.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix return value handling for libustcmd
[ust.git]
/
libustcmd
/
ustcmd.c
diff --git
a/libustcmd/ustcmd.c
b/libustcmd/ustcmd.c
index 46a95618439915336fc654f9a90495b479d11039..f0a6ae0a25059cfcaead24f313c0b926e5ccb02a 100644
(file)
--- a/
libustcmd/ustcmd.c
+++ b/
libustcmd/ustcmd.c
@@
-25,7
+25,7
@@
#include <dirent.h>
#include "ustcomm.h"
#include <dirent.h>
#include "ustcomm.h"
-#include "ustcmd.h"
+#include "ust
/ust
cmd.h"
#include "usterr.h"
pid_t *ustcmd_get_online_pids(void)
#include "usterr.h"
pid_t *ustcmd_get_online_pids(void)
@@
-90,10
+90,14
@@
int ustcmd_set_marker_state(const char *mn, int state, pid_t pid)
return USTCMD_ERR_ARG;
}
return USTCMD_ERR_ARG;
}
- asprintf(&cmd, "%s %s", cmd_str[state], mn);
+ if (asprintf(&cmd, "%s %s", cmd_str[state], mn) < 0) {
+ ERR("ustcmd_set_marker_state : asprintf failed (%s %s)",
+ cmd_str[state], mn);
+ return USTCMD_ERR_GEN;
+ }
result = ustcmd_send_cmd(cmd, pid, NULL);
result = ustcmd_send_cmd(cmd, pid, NULL);
- if (result) {
+ if (result
!= 1
) {
free(cmd);
return USTCMD_ERR_GEN;
}
free(cmd);
return USTCMD_ERR_GEN;
}
@@
-114,7
+118,11
@@
int ustcmd_set_subbuf_size(const char *channel_size, pid_t pid)
char *cmd;
int result;
char *cmd;
int result;
- asprintf(&cmd, "%s %s", "set_subbuf_size", channel_size);
+ if (asprintf(&cmd, "%s %s", "set_subbuf_size", channel_size) < 0) {
+ ERR("ustcmd_set_subbuf_size : asprintf failed (set_subbuf_size %s)",
+ channel_size);
+ return -1;
+ }
result = ustcmd_send_cmd(cmd, pid, NULL);
if (result != 1) {
result = ustcmd_send_cmd(cmd, pid, NULL);
if (result != 1) {
@@
-138,7
+146,11
@@
int ustcmd_set_subbuf_num(const char *channel_size, pid_t pid)
char *cmd;
int result;
char *cmd;
int result;
- asprintf(&cmd, "%s %s", "set_subbuf_num", channel_size);
+ if (asprintf(&cmd, "%s %s", "set_subbuf_num", channel_size) < 0) {
+ ERR("ustcmd_set_subbuf_num : asprintf failed (set_subbuf_num %s",
+ channel_size);
+ return -1;
+ }
result = ustcmd_send_cmd(cmd, pid, NULL);
if (result != 1) {
result = ustcmd_send_cmd(cmd, pid, NULL);
if (result != 1) {
@@
-163,12
+175,15
@@
int ustcmd_get_subbuf_size(const char *channel, pid_t pid)
int result;
/* format: channel_cpu */
int result;
/* format: channel_cpu */
- asprintf(&cmd, "%s %s_0", "get_subbuf_size", channel);
+ if (asprintf(&cmd, "%s %s_0", "get_subbuf_size", channel) < 0) {
+ ERR("ustcmd_get_subbuf_size : asprintf failed (get_subbuf_size, %s_0",
+ channel);
+ return -1;
+ }
result = ustcmd_send_cmd(cmd, pid, &reply);
result = ustcmd_send_cmd(cmd, pid, &reply);
- if (result) {
+ if (result
!= 1
) {
free(cmd);
free(cmd);
- free(reply);
return -1;
}
return -1;
}
@@
-191,12
+206,15
@@
int ustcmd_get_subbuf_num(const char *channel, pid_t pid)
int result;
/* format: channel_cpu */
int result;
/* format: channel_cpu */
- asprintf(&cmd, "%s %s_0", "get_n_subbufs", channel);
+ if (asprintf(&cmd, "%s %s_0", "get_n_subbufs", channel) < 0) {
+ ERR("ustcmd_get_subbuf_num : asprintf failed (get_n_subbufs, %s_0",
+ channel);
+ return -1;
+ }
result = ustcmd_send_cmd(cmd, pid, &reply);
result = ustcmd_send_cmd(cmd, pid, &reply);
- if (result) {
+ if (result
!= 1
) {
free(cmd);
free(cmd);
- free(reply);
return -1;
}
return -1;
}
@@
-432,7
+450,11
@@
int ustcmd_set_sock_path(const char *sock_path, pid_t pid)
char *cmd;
int result;
char *cmd;
int result;
- asprintf(&cmd, "%s %s", "set_sock_path", sock_path);
+ if (asprintf(&cmd, "%s %s", "set_sock_path", sock_path) < 0) {
+ ERR("ustcmd_set_sock_path : asprintf failed (set_sock_path, %s",
+ sock_path);
+ return -1;
+ }
result = ustcmd_send_cmd(cmd, pid, NULL);
if (result != 1) {
result = ustcmd_send_cmd(cmd, pid, NULL);
if (result != 1) {
@@
-456,12
+478,14
@@
int ustcmd_get_sock_path(char **sock_path, pid_t pid)
char *cmd, *reply;
int result;
char *cmd, *reply;
int result;
- asprintf(&cmd, "%s", "get_sock_path");
+ if (asprintf(&cmd, "%s", "get_sock_path") < 0) {
+ ERR("ustcmd_get_sock_path : asprintf failed");
+ return USTCMD_ERR_GEN;
+ }
result = ustcmd_send_cmd(cmd, pid, &reply);
if (result != 1) {
free(cmd);
result = ustcmd_send_cmd(cmd, pid, &reply);
if (result != 1) {
free(cmd);
- free(reply);
return USTCMD_ERR_GEN;
}
return USTCMD_ERR_GEN;
}
@@
-489,7
+513,7
@@
int ustcmd_force_switch(pid_t pid)
* @param pid Targeted PID
* @param reply Pointer to string to be filled with a reply string (must
* be NULL if no reply is needed for the given command).
* @param pid Targeted PID
* @param reply Pointer to string to be filled with a reply string (must
* be NULL if no reply is needed for the given command).
- * @return -1 if successful, 0 on EOT, 1 on success
+ * @return -1 if
not
successful, 0 on EOT, 1 on success
*/
int ustcmd_send_cmd(const char *cmd, const pid_t pid, char **reply)
*/
int ustcmd_send_cmd(const char *cmd, const pid_t pid, char **reply)
This page took
0.024562 seconds
and
4
git commands to generate.