aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--trace-output.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/trace-output.c b/trace-output.c
index 46afe48..194446b 100644
--- a/trace-output.c
+++ b/trace-output.c
@@ -80,6 +80,14 @@ do_write_check(struct tracecmd_output *handle, void *data, int size)
80 return __do_write_check(handle->fd, data, size); 80 return __do_write_check(handle->fd, data, size);
81} 81}
82 82
83static short convert_endian_2(struct tracecmd_output *handle, short val)
84{
85 if (!handle->pevent)
86 return val;
87
88 return __data2host2(handle->pevent, val);
89}
90
83static int convert_endian_4(struct tracecmd_output *handle, int val) 91static int convert_endian_4(struct tracecmd_output *handle, int val)
84{ 92{
85 if (!handle->pevent) 93 if (!handle->pevent)
@@ -857,6 +865,8 @@ int tracecmd_add_option(struct tracecmd_output *handle,
857static int add_options(struct tracecmd_output *handle) 865static int add_options(struct tracecmd_output *handle)
858{ 866{
859 unsigned short option; 867 unsigned short option;
868 unsigned short endian2;
869 unsigned int endian4;
860 int i; 870 int i;
861 871
862 if (handle->options_written) 872 if (handle->options_written)
@@ -866,10 +876,12 @@ static int add_options(struct tracecmd_output *handle)
866 return -1; 876 return -1;
867 877
868 for (i = 0; i < handle->nr_options; i++) { 878 for (i = 0; i < handle->nr_options; i++) {
869 if (do_write_check(handle, &handle->options[i].id, 2)) 879 endian2 = convert_endian_2(handle, handle->options[i].id);
880 if (do_write_check(handle, &endian2, 2))
870 return -1; 881 return -1;
871 882
872 if (do_write_check(handle, &handle->options[i].size, 4)) 883 endian4 = convert_endian_4(handle, handle->options[i].size);
884 if (do_write_check(handle, &endian4, 4))
873 return -1; 885 return -1;
874 886
875 if (do_write_check(handle, handle->options[i].data, 887 if (do_write_check(handle, handle->options[i].data,