Skip to content

Commit

Permalink
Add run_system_wrapper() which supports multi-variable arguments
Browse files Browse the repository at this point in the history
This can reduce the lines of code as opposed to using run_system()
directly.

Signed-off-by: Adil Saeed Musthafa <adilm@qti.qualcomm.com>
  • Loading branch information
Adil Saeed Musthafa authored and jmalinen committed Apr 11, 2017
1 parent 33ea287 commit 5f793f0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions p2p.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,31 @@ int run_system(struct sigma_dut *dut, const char *cmd)
}


int run_system_wrapper(struct sigma_dut *dut, const char *cmd, ...)
{
va_list ap;
char *buf;
int bytes_required;
int res;

va_start(ap, cmd);
bytes_required = vsnprintf(NULL, 0, cmd, ap);
bytes_required += 1;
va_end(ap);
buf = malloc(bytes_required);
if (!buf) {
printf("ERROR!! No memory\n");
return -1;
}
va_start(ap, cmd);
vsnprintf(buf, bytes_required, cmd, ap);
va_end(ap);
res = run_system(dut, buf);
free(buf);
return res;
}


static int get_60g_freq(int chan)
{
int freq = 0;
Expand Down
1 change: 1 addition & 0 deletions sigma_dut.h
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ int get_ip_config(struct sigma_dut *dut, const char *ifname, char *buf,
int ath6kl_client_uapsd(struct sigma_dut *dut, const char *intf, int uapsd);
int is_ip_addr(const char *str);
int run_system(struct sigma_dut *dut, const char *cmd);
int run_system_wrapper(struct sigma_dut *dut, const char *cmd, ...);
int cmd_wlantest_set_channel(struct sigma_dut *dut, struct sigma_conn *conn,
struct sigma_cmd *cmd);
void sniffer_close(struct sigma_dut *dut);
Expand Down

0 comments on commit 5f793f0

Please sign in to comment.