shared: const correctness 90/172890/3
authorMichal Bloch <m.bloch@samsung.com>
Fri, 16 Mar 2018 12:37:40 +0000 (13:37 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Mon, 19 Mar 2018 12:43:56 +0000 (13:43 +0100)
An unneeded line was preventing a handful of functions from being const.

Change-Id: I34f288f828505f4fd1a133efaaf3cb1f0d7656e1
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
include/log_file.h
include/logprint.h
src/logutil/logutil.c
src/shared/log_file.c
src/shared/logprint.c

index f148234..57f38c2 100644 (file)
@@ -52,7 +52,7 @@ int logfile_set_path(struct log_file *l_file, const char *path);
 int logfile_open(struct log_file *l_file, logfile_hook_fn open_fn);
 int logfile_rotate_needed(struct log_file *l_file);
 void logfile_do_rotate(struct log_file *file);
-int logfile_write_with_rotation(struct logger_entry *e, struct log_file *file);
+int logfile_write_with_rotation(const struct logger_entry *e, struct log_file *file);
 
 #ifdef __cplusplus
 }
index b5bc882..fba8408 100644 (file)
@@ -55,9 +55,9 @@ typedef struct log_entry_t {
        log_priority priority;
        pid_t pid;
        pthread_t tid;
-       char * tag;
+       const char *tag;
        size_t messageLen;
-       char * message;
+       const char *message;
 } log_entry;
 
 log_format *log_format_new();
@@ -144,7 +144,7 @@ bool log_should_print_line(
  * Returns 0 on success and -1 on invalid wire format (entry will be
  * in unspecified state)
  */
-int log_process_log_buffer(struct logger_entry *entry_raw, log_entry *entry);
+int log_process_log_buffer(const struct logger_entry *entry_raw, log_entry *entry);
 
 /**
  * Formats a log message into a buffer
index 73f5ab1..2e3ce47 100755 (executable)
@@ -61,7 +61,7 @@ typedef enum action_e {
  * @param[in] timeout Sort timeout in ms
  * @return 1 if the log was old enough, else 0
  */
-static int process_log(struct logger_entry *e, struct timespec ts, struct log_file *l_file, long timeout)
+static int process_log(const struct logger_entry *e, struct timespec ts, struct log_file *l_file, long timeout)
 {
        assert(e);
        assert(l_file);
index 769159a..4b519b3 100644 (file)
@@ -216,7 +216,7 @@ void logfile_do_rotate(struct log_file *file)
  * @param[in] file The file to write to
  * @returns 0 if log was successfully written, else 1
  */
-int logfile_write_with_rotation(struct logger_entry *e, struct log_file *file)
+int logfile_write_with_rotation(const struct logger_entry *e, struct log_file *file)
 {
        log_entry entry;
        if (log_process_log_buffer(e, &entry) || !log_should_print_line(file->format, &entry))
index 4aa7167..1c2272c 100644 (file)
@@ -555,7 +555,7 @@ int log_add_filter_tid(log_format *p_format, pthread_t tid)
  * @param[out] entry The entry to fill
  * @return 0 on success, -1 on failure
  */
-int log_process_log_buffer(struct logger_entry *entry_raw, log_entry *entry)
+int log_process_log_buffer(const struct logger_entry *entry_raw, log_entry *entry)
 {
        //TODO: remove and make log_format_log_line just use raw entry directly
        int i, start = -1, end = -1;
@@ -599,10 +599,8 @@ int log_process_log_buffer(struct logger_entry *entry_raw, log_entry *entry)
                fprintf(stderr, "Malformed log message\n");
                return -1;
        }
-       if (end == -1) {
+       if (end == -1)
                end = entry_raw->len - 1;
-               entry_raw->msg[end] = '\0';
-       }
 
        entry->message = entry_raw->msg + start;
        entry->messageLen = end - start;