[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Use `const char *` instead of `char *` for line parameter for process callbacks.
commit cacdd290872420d51f880d75466f6d6e22430466
Author: Alexander Færøy <ahf@xxxxxxxxxxxxxx>
Date: Fri Dec 7 02:09:22 2018 +0100
Use `const char *` instead of `char *` for line parameter for process callbacks.
This patch changes the type definition of the process callbacks to use
`const char *` instead of `char *`.
See: https://bugs.torproject.org/28179
---
src/feature/client/transports.c | 8 ++++++--
src/feature/client/transports.h | 4 ++--
src/lib/process/process.h | 2 +-
src/test/test_process.c | 4 ++--
src/test/test_process_slow.c | 4 ++--
5 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/feature/client/transports.c b/src/feature/client/transports.c
index df7991846..0f456ba1e 100644
--- a/src/feature/client/transports.c
+++ b/src/feature/client/transports.c
@@ -1711,7 +1711,9 @@ tor_escape_str_for_pt_args(const char *string, const char *chars_to_escape)
* stdout. Our process can be found in <b>process</b>, the data can be found in
* <b>line</b> and the length of our line is given in <b>size</b>. */
STATIC void
-managed_proxy_stdout_callback(process_t *process, char *line, size_t size)
+managed_proxy_stdout_callback(process_t *process,
+ const char *line,
+ size_t size)
{
tor_assert(process);
tor_assert(line);
@@ -1732,7 +1734,9 @@ managed_proxy_stdout_callback(process_t *process, char *line, size_t size)
* stderr. Our process can be found in <b>process</b>, the data can be found in
* <b>line</b> and the length of our line is given in <b>size</b>. */
STATIC void
-managed_proxy_stderr_callback(process_t *process, char *line, size_t size)
+managed_proxy_stderr_callback(process_t *process,
+ const char *line,
+ size_t size)
{
tor_assert(process);
tor_assert(line);
diff --git a/src/feature/client/transports.h b/src/feature/client/transports.h
index 88735a721..a3994a009 100644
--- a/src/feature/client/transports.h
+++ b/src/feature/client/transports.h
@@ -143,8 +143,8 @@ STATIC char* get_pt_proxy_uri(void);
STATIC void free_execve_args(char **arg);
-STATIC void managed_proxy_stdout_callback(process_t *, char *, size_t);
-STATIC void managed_proxy_stderr_callback(process_t *, char *, size_t);
+STATIC void managed_proxy_stdout_callback(process_t *, const char *, size_t);
+STATIC void managed_proxy_stderr_callback(process_t *, const char *, size_t);
STATIC bool managed_proxy_exit_callback(process_t *, process_exit_code_t);
#endif /* defined(PT_PRIVATE) */
diff --git a/src/lib/process/process.h b/src/lib/process/process.h
index 4b0fae425..179db19ae 100644
--- a/src/lib/process/process.h
+++ b/src/lib/process/process.h
@@ -54,7 +54,7 @@ typedef uint64_t process_exit_code_t;
typedef uint64_t process_pid_t;
typedef void (*process_read_callback_t)(process_t *,
- char *,
+ const char *,
size_t);
typedef bool
(*process_exit_callback_t)(process_t *, process_exit_code_t);
diff --git a/src/test/test_process.c b/src/test/test_process.c
index 17481097b..9b62862f0 100644
--- a/src/test/test_process.c
+++ b/src/test/test_process.c
@@ -98,7 +98,7 @@ process_mocked_write_stdin(process_t *process, buf_t *buffer)
}
static void
-process_stdout_callback(process_t *process, char *data, size_t size)
+process_stdout_callback(process_t *process, const char *data, size_t size)
{
tt_ptr_op(process, OP_NE, NULL);
tt_ptr_op(data, OP_NE, NULL);
@@ -112,7 +112,7 @@ process_stdout_callback(process_t *process, char *data, size_t size)
}
static void
-process_stderr_callback(process_t *process, char *data, size_t size)
+process_stderr_callback(process_t *process, const char *data, size_t size)
{
tt_ptr_op(process, OP_NE, NULL);
tt_ptr_op(data, OP_NE, NULL);
diff --git a/src/test/test_process_slow.c b/src/test/test_process_slow.c
index b23492e97..cc7e8c5a9 100644
--- a/src/test/test_process_slow.c
+++ b/src/test/test_process_slow.c
@@ -67,7 +67,7 @@ process_data_free(process_data_t *process_data)
}
static void
-process_stdout_callback(process_t *process, char *data, size_t size)
+process_stdout_callback(process_t *process, const char *data, size_t size)
{
tt_ptr_op(process, OP_NE, NULL);
tt_ptr_op(data, OP_NE, NULL);
@@ -81,7 +81,7 @@ process_stdout_callback(process_t *process, char *data, size_t size)
}
static void
-process_stderr_callback(process_t *process, char *data, size_t size)
+process_stderr_callback(process_t *process, const char *data, size_t size)
{
tt_ptr_op(process, OP_NE, NULL);
tt_ptr_op(data, OP_NE, NULL);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits