Clarify function names: getsize → get capacity 21/233421/5
authorAgnieszka Baumann <a.baumann@samsung.com>
Thu, 14 May 2020 08:40:41 +0000 (10:40 +0200)
committerAgnieszka Baumann <a.baumann@samsung.com>
Tue, 9 Jun 2020 08:32:54 +0000 (10:32 +0200)
Change-Id: I28955dd2359498370756555cbd88d6ff5a1fb7e1

13 files changed:
include/dlogutil.h
include/fd_info.h
include/logpipe.h
src/libdlogutil/fdi_logger.c
src/libdlogutil/fdi_pipe.c
src/libdlogutil/lib.c
src/logger/logger.c
src/logutil/logutil.c
src/tests/fdi_logger_neg.c
src/tests/fdi_logger_pos.c
src/tests/fdi_pipe_neg.c
src/tests/fdi_pipe_pos.c
tests/test_libdlogutil_legacy.c

index 4815641..0d80ef9 100644 (file)
@@ -533,7 +533,7 @@ int dlogutil_buffer_clear(dlogutil_buffer_e buffer);
 int dlogutil_buffer_get_name(dlogutil_buffer_e buffer, const char **name);
 
 /**
- * @brief Gets the size of a buffer.
+ * @brief Gets the capacity of a buffer.
  * @since_tizen 6.0
  * @remarks Either CAP_SYSLOG or being in the log group is required.
  * @bug This is currently evaluated using the config file, which can change at runtime. In particular,
@@ -541,7 +541,7 @@ int dlogutil_buffer_get_name(dlogutil_buffer_e buffer, const char **name);
  *      a theoretical concern, since the file is not intended to change during the runtime (the daemon asks
  *      to reboot the system in such a case).
  * @param[in] buffer A single buffer to be inspected
- * @param[out] size The size in entries of the passed buffer
+ * @param[out] capacity The buffer's maximum capacity, in bytes
  * @return An error code
  * @retval TIZEN_ERROR_NONE Success
  * @retval TIZEN_ERROR_INVALID_PARAMETER Invalid buffer
@@ -549,7 +549,7 @@ int dlogutil_buffer_get_name(dlogutil_buffer_e buffer, const char **name);
  * @retval TIZEN_ERROR_INVALID_PARAMETER The pointer was NULL
  * @retval Other An arbitrary Tizen error code
  */
-int dlogutil_buffer_get_size(dlogutil_buffer_e buffer, unsigned int *size);
+int dlogutil_buffer_get_capacity(dlogutil_buffer_e buffer, unsigned int *capacity);
 
 /**
  * @brief Gets the default timestamp type of a buffer.
index 47981f7..64574f1 100644 (file)
@@ -59,8 +59,8 @@ struct fd_ops {
        /// Clear the buffer
        int (*clear)(struct fd_info *fdi);
 
-       /// Get the size of the buffer
-       int (*getsize)(struct fd_info *fdi, unsigned int *val);
+       /// Get the capacity of the buffer
+       int (*get_capacity)(struct fd_info *fdi, unsigned int *capacity);
 
        /// Check whether there will be no more logs on this FD
        bool (*eof)(const struct fd_info *fdi);
index 42f7652..0377453 100644 (file)
@@ -27,7 +27,7 @@ enum {
        DLOG_REQ_PIPE           = 1 << 1,
        DLOG_REQ_CLEAR          = 1 << 2,
        DLOG_REQ_HANDLE_LOGUTIL = 1 << 3,
-       DLOG_REQ_GETSIZE        = 1 << 4,
+       DLOG_REQ_GET_CAPACITY   = 1 << 4,
 };
 
 enum {
index 544eac3..27f8c76 100644 (file)
@@ -49,7 +49,7 @@ static int logger_ioctl(int fd, int ioctl_id)
        return ret;
 }
 
-static int logger_getsize(struct fd_info *fdi, unsigned int *val)
+static int logger_get_capacity(struct fd_info *fdi, unsigned int *capacity)
 {
        assert(fdi);
 
@@ -57,7 +57,7 @@ static int logger_getsize(struct fd_info *fdi, unsigned int *val)
        if (r < 0)
                return r;
 
-       *val = (unsigned int)r;
+       *capacity = (unsigned int)r;
        return 0;
 }
 
@@ -338,7 +338,7 @@ const struct fd_ops ops_logger = {
        .peek_entry = logger_peek_entry,
        .prepare_print = logger_prepare_print,
        .clear = logger_clear,
-       .getsize = logger_getsize,
+       .get_capacity = logger_get_capacity,
        .eof = logger_eof,
        .should_filter = true,
 };
index cd06fd6..9b79d69 100644 (file)
 #include "fdi_pipe.h"
 #include "fdi_pipe_internal.h"
 
-static int pipe_getsize(struct fd_info *fdi, unsigned int *val)
+static int pipe_get_capacity(struct fd_info *fdi, unsigned int *capacity)
 {
        assert(fdi);
        struct pipe_priv_data *ppd = (struct pipe_priv_data *)fdi->priv_data;
        assert(ppd);
        assert(ppd->sock_fd >= 0);
 
-       int r = send_dlog_request(ppd->sock_fd, DLOG_REQ_GETSIZE, NULL, 0);
+       int r = send_dlog_request(ppd->sock_fd, DLOG_REQ_GET_CAPACITY, NULL, 0);
        if (r < 0)
                return r;
 
        unsigned int *data;
        int datalen;
-       r = recv_dlog_reply(ppd->sock_fd, DLOG_REQ_GETSIZE, (void **)&data, &datalen);
+       r = recv_dlog_reply(ppd->sock_fd, DLOG_REQ_GET_CAPACITY, (void **)&data, &datalen);
        if (r < 0)
                goto cleanup;
        if (!data || datalen != sizeof *data) {
                r = -EINVAL;
                goto cleanup;
        }
-       *val = *data;
+       *capacity = *data;
 
 cleanup:
        free(data);
@@ -300,7 +300,7 @@ const struct fd_ops ops_pipe = {
        .peek_entry = pipe_peek_entry,
        .prepare_print = pipe_prepare_print,
        .clear = pipe_clear,
-       .getsize = pipe_getsize,
+       .get_capacity = pipe_get_capacity,
        .eof = pipe_eof,
        .should_filter = false,
 };
index fcec2e8..52da108 100644 (file)
@@ -197,13 +197,13 @@ EXPORT_API int dlogutil_buffer_get_name(dlogutil_buffer_e buffer, const char **n
        return TIZEN_ERROR_NONE;
 }
 
-EXPORT_API int dlogutil_buffer_get_size(dlogutil_buffer_e buffer, unsigned int *size)
+EXPORT_API int dlogutil_buffer_get_capacity(dlogutil_buffer_e buffer, unsigned int *capacity)
 {
-       CHECK_PARAM(size);
+       CHECK_PARAM(capacity);
 
        COMMON_INIT_SINGLE
 
-       return fdi_ptrs[0]->ops->getsize(fdi_ptrs[0], size);
+       return fdi_ptrs[0]->ops->get_capacity(fdi_ptrs[0], capacity);
 }
 
 EXPORT_API int dlogutil_buffer_get_default_ts_type(dlogutil_buffer_e buffer, dlogutil_sorting_order_e *type)
index 7abd953..39447a0 100644 (file)
@@ -1295,16 +1295,16 @@ static int service_writer_handle_req_util(struct logger* server, struct writer*
        return 0;
 }
 
-static int service_writer_handle_req_getsize(struct logger *server, struct writer *wr, struct dlog_control_msg *msg)
+static int service_writer_handle_req_get_capacity(struct logger *server, struct writer *wr, struct dlog_control_msg *msg)
 {
        assert(server);
        assert(wr);
        assert(msg);
-       assert(msg->request == DLOG_REQ_GETSIZE);
+       assert(msg->request == DLOG_REQ_GET_CAPACITY);
 
        uint32_t buf_size = log_storage_get_capacity(wr->buf_ptr->log_storage);
 
-       return send_dlog_reply(wr->fd_entity.fd, DLOG_REQ_GETSIZE, DLOG_REQ_RESULT_OK, &buf_size, sizeof buf_size);
+       return send_dlog_reply(wr->fd_entity.fd, DLOG_REQ_GET_CAPACITY, DLOG_REQ_RESULT_OK, &buf_size, sizeof buf_size);
 }
 
 /**
@@ -1361,8 +1361,8 @@ static int service_writer_handle_req_ctrl(struct logger *server, struct writer *
                return service_writer_handle_req_clear(server, wr, msg);
        case DLOG_REQ_HANDLE_LOGUTIL:
                return service_writer_handle_req_util(server, wr, msg);
-       case DLOG_REQ_GETSIZE:
-               return service_writer_handle_req_getsize(server, wr, msg);
+       case DLOG_REQ_GET_CAPACITY:
+               return service_writer_handle_req_get_capacity(server, wr, msg);
        default:
                return -EINVAL;
        }
index d607389..eda2fa0 100644 (file)
@@ -41,7 +41,7 @@ static const int default_buffers = (1 << LOG_ID_MAIN) | (1 << LOG_ID_SYSTEM) | (
 
 typedef enum action_e {
        ACTION_PRINT = 0,
-       ACTION_GETSIZE,
+       ACTION_GET_CAPACITY,
        ACTION_CLEAR,
 } action_e;
 
@@ -137,7 +137,7 @@ static int parse_options(int argc, char **argv, struct log_file *l_file, int *en
                        *action = ACTION_CLEAR;
                        break;
                case 'g':
-                       *action = ACTION_GETSIZE;
+                       *action = ACTION_GET_CAPACITY;
                        break;
                case 'b': {
                        log_id_t id = log_id_by_name(optarg);
@@ -249,19 +249,19 @@ static void sorting_cleanup(dlogutil_sorting_options_s *const *sorting) {
        dlogutil_sorting_options_destroy(*sorting);
 }
 
-static int print_buffer_size(dlogutil_buffer_e buffer)
+static int print_buffer_capacity(dlogutil_buffer_e buffer)
 {
        const char *name;
        int r = dlogutil_buffer_get_name(buffer, &name);
        if (r != 0)
                return r;
 
-       unsigned int size;
-       r = dlogutil_buffer_get_size(buffer, &size);
+       unsigned int capacity;
+       r = dlogutil_buffer_get_capacity(buffer, &capacity);
        if (r != 0)
                return r;
 
-       printf("%s: %u KiB\n", name, BtoKiB(size));
+       printf("%s: %u KiB\n", name, BtoKiB(capacity));
        return 0;
 }
 
@@ -388,8 +388,8 @@ int main(int argc, char **argv)
                r = do_print(mode, enabled_buffers, monitor, sort_by, sorting, filter, &l_file);
                break;
        }
-       case ACTION_GETSIZE: {
-               r = for_each_buffer(enabled_buffers, print_buffer_size);
+       case ACTION_GET_CAPACITY: {
+               r = for_each_buffer(enabled_buffers, print_buffer_capacity);
                break;
        }
        case ACTION_CLEAR:
@@ -400,7 +400,7 @@ int main(int argc, char **argv)
        if (r < 0) {
                static const char *action_names[] = {
                        [ACTION_PRINT] = "printing logs",
-                       [ACTION_GETSIZE] = "getting size",
+                       [ACTION_GET_CAPACITY] = "getting capacity",
                        [ACTION_CLEAR] = "clearing buffer",
                };
                errno = -r;
index 9fbacd9..a41c4af 100644 (file)
@@ -65,7 +65,7 @@ int main()
        unsigned int sz;
        expected_ioctl = LOGGER_GET_LOG_BUF_SIZE;
        ioctl_ret = -EALREADY;
-       assert(-EALREADY == ops_logger.getsize(&fdi, &sz));
+       assert(-EALREADY == ops_logger.get_capacity(&fdi, &sz));
 
        expected_ioctl = LOGGER_GET_LOG_LEN;
        ioctl_ret = -67;
index 814f5a8..b2b881a 100644 (file)
@@ -42,7 +42,7 @@ int main()
        unsigned int sz;
        expected_ioctl = LOGGER_GET_LOG_BUF_SIZE;
        ioctl_ret = 2019;
-       assert(0 == ops_logger.getsize(&fdi, &sz));
+       assert(0 == ops_logger.get_capacity(&fdi, &sz));
        assert(2019 == sz);
 
        expected_ioctl = LOGGER_GET_LOG_LEN;
index 9a55ce6..4de6f20 100644 (file)
@@ -93,17 +93,17 @@ int main()
        send_return = -1;
        assert(ops_pipe.clear(&info) == -1);
 
-       correct_request = DLOG_REQ_GETSIZE;
+       correct_request = DLOG_REQ_GET_CAPACITY;
        correct_send_data = NULL;
        correct_send_datalen = 0;
        unsigned int size_target = 0;
 
        send_return = -1;
-       assert(ops_pipe.getsize(&info, &size_target) == -1);
+       assert(ops_pipe.get_capacity(&info, &size_target) == -1);
 
        send_return = 0;
        recv_return = -1;
-       assert(ops_pipe.getsize(&info, &size_target) == -1);
+       assert(ops_pipe.get_capacity(&info, &size_target) == -1);
 
        recv_return = 0;
        const char *wrong_ans = "I won't tell you the pipe size :)";
@@ -112,12 +112,12 @@ int main()
        assert(recv_data);
        memcpy(recv_data, wrong_ans, recv_datalen);
        ptr_to_free = recv_data;
-       assert(ops_pipe.getsize(&info, &size_target) == -EINVAL);
+       assert(ops_pipe.get_capacity(&info, &size_target) == -EINVAL);
        assert(ptr_to_free == NULL);
 
        recv_datalen = 0;
        recv_data = NULL;
-       assert(ops_pipe.getsize(&info, &size_target) == -EINVAL);
+       assert(ops_pipe.get_capacity(&info, &size_target) == -EINVAL);
 
        ops_pipe.destroy(&info);
        ops_pipe.destroy(&info);
index 7c84b4a..92883b2 100644 (file)
@@ -129,7 +129,7 @@ ok:
        send_return = 0;
        assert(ops_pipe.clear(&info) == 0);
 
-       correct_request = DLOG_REQ_GETSIZE;
+       correct_request = DLOG_REQ_GET_CAPACITY;
        unsigned int size_target = 0;
        recv_return = 0;
 
@@ -138,7 +138,7 @@ ok:
        assert(recv_data);
        *(int *)recv_data = (unsigned int)17;
        ptr_to_free = recv_data;
-       assert(ops_pipe.getsize(&info, &size_target) == 0);
+       assert(ops_pipe.get_capacity(&info, &size_target) == 0);
        assert(ptr_to_free == NULL);
        assert(size_target == 17);
 
index 2e2a969..0b58d9b 100644 (file)
@@ -162,19 +162,19 @@ void traits_main(bool pipe)
        assert(dlogutil_buffer_get_name(DLOGUTIL_BUF_KMSG, &name) == 0);
        assert(!strcmp(name, "kmsg"));
 
-       unsigned int size;
-       assert(dlogutil_buffer_get_size(DLOGUTIL_BUF_MAIN, &size) == 0);
+       unsigned int capacity;
+       assert(dlogutil_buffer_get_capacity(DLOGUTIL_BUF_MAIN, &capacity) == 0);
        if (pipe)
-               assert(size == MB(1));
+               assert(capacity == MB(1));
        else {
                int fd = open("/dev/log_main", O_RDONLY);
-               int real_size = ioctl(fd, LOGGER_GET_LOG_BUF_SIZE);
+               int real_capacity = ioctl(fd, LOGGER_GET_LOG_BUF_SIZE);
                close(fd);
-               assert(size == real_size);
+               assert(capacity == real_capacity);
        }
 
-       assert(dlogutil_buffer_get_size(DLOGUTIL_BUF_KMSG, &size) == 0);
-       assert(size == MB(1));
+       assert(dlogutil_buffer_get_capacity(DLOGUTIL_BUF_KMSG, &capacity) == 0);
+       assert(capacity == MB(1));
 
        dlogutil_sorting_order_e type;
        assert(dlogutil_buffer_get_default_ts_type(DLOGUTIL_BUF_MAIN, &type) == 0);
@@ -239,17 +239,17 @@ void negative_main()
        // Invalid single buffer
        assert(dlogutil_buffer_clear(0) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_get_name(0, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
-       assert(dlogutil_buffer_get_size(0, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
+       assert(dlogutil_buffer_get_capacity(0, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_get_default_ts_type(0, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_check_ts_type_available(0, DLOGUTIL_SORT_RECV_MONO, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_clear(1 << 16) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_get_name(1 << 16, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
-       assert(dlogutil_buffer_get_size(1 << 16, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
+       assert(dlogutil_buffer_get_capacity(1 << 16, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_get_default_ts_type(1 << 16, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_check_ts_type_available(1 << 16, DLOGUTIL_SORT_RECV_MONO, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_clear(DLOGUTIL_BUF_MAIN | DLOGUTIL_BUF_KMSG) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_get_name(DLOGUTIL_BUF_MAIN | DLOGUTIL_BUF_KMSG, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
-       assert(dlogutil_buffer_get_size(DLOGUTIL_BUF_MAIN | DLOGUTIL_BUF_KMSG, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
+       assert(dlogutil_buffer_get_capacity(DLOGUTIL_BUF_MAIN | DLOGUTIL_BUF_KMSG, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_get_default_ts_type(DLOGUTIL_BUF_MAIN | DLOGUTIL_BUF_KMSG, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_check_ts_type_available(DLOGUTIL_BUF_MAIN | DLOGUTIL_BUF_KMSG, DLOGUTIL_SORT_RECV_MONO, bad_ptr) == TIZEN_ERROR_INVALID_PARAMETER);
 
@@ -269,7 +269,7 @@ void negative_main()
        assert(dlogutil_entry_get_tag(bad_ptr, NULL) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_entry_get_message(bad_ptr, NULL) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_get_name(DLOGUTIL_BUF_MAIN, NULL) == TIZEN_ERROR_INVALID_PARAMETER);
-       assert(dlogutil_buffer_get_size(DLOGUTIL_BUF_MAIN, NULL) == TIZEN_ERROR_INVALID_PARAMETER);
+       assert(dlogutil_buffer_get_capacity(DLOGUTIL_BUF_MAIN, NULL) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_get_default_ts_type(DLOGUTIL_BUF_MAIN, NULL) == TIZEN_ERROR_INVALID_PARAMETER);
        assert(dlogutil_buffer_check_ts_type_available(DLOGUTIL_BUF_MAIN, DLOGUTIL_SORT_RECV_MONO, NULL) == TIZEN_ERROR_INVALID_PARAMETER);