config: rename parse_logsize to be more generic

Rename config_parse_logsize to config_parse_bytesize.
A more generic name allows this function to be reused in other
config parsing purposes.

Change-Id: I3036c184669be17ddc0d194f275ea05d871341d1
Signed-off-by: Medicine Yeh <medicinehy@gmail.com>
diff --git a/config.c b/config.c
index 3b8aef9..5f5edaf 100644
--- a/config.c
+++ b/config.c
@@ -276,7 +276,7 @@
 	return 0;
 }
 
-int config_parse_logsize(const char *size_str, size_t *size)
+int config_parse_bytesize(const char *size_str, size_t *size)
 {
 	struct size_suffix_shift {
 		/* Left shiftwidth corresponding to the suffix. */
diff --git a/console-server.h b/console-server.h
index 47302dc..3de3ece 100644
--- a/console-server.h
+++ b/console-server.h
@@ -216,7 +216,7 @@
 int config_parse_baud(speed_t *speed, const char *baud_string);
 uint32_t parse_baud_to_int(speed_t speed);
 speed_t parse_int_to_baud(uint32_t baud);
-int config_parse_logsize(const char *size_str, size_t *size);
+int config_parse_bytesize(const char *size_str, size_t *size);
 
 /* socket paths */
 ssize_t console_socket_path(socket_path_t path, const char *id);
diff --git a/log-handler.c b/log-handler.c
index ab30827..a545505 100644
--- a/log-handler.c
+++ b/log-handler.c
@@ -142,7 +142,7 @@
 	lh->rotate_filename = NULL;
 
 	logsize_str = config_get_value(config, "logsize");
-	rc = config_parse_logsize(logsize_str, &logsize);
+	rc = config_parse_bytesize(logsize_str, &logsize);
 	if (logsize_str != NULL && rc) {
 		logsize = default_logsize;
 		warn("Invalid logsize. Default to %ukB",
diff --git a/test/meson.build b/test/meson.build
index 0d08d19..39c9784 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -1,7 +1,7 @@
 tests = [
 	'test-client-escape',
 	'test-config-parse',
-	'test-config-parse-logsize',
+	'test-config-parse-bytesize',
 	'test-config-resolve-console-id',
 	'test-ringbuffer-boundary-poll',
 	'test-ringbuffer-boundary-read',
diff --git a/test/test-config-parse-logsize.c b/test/test-config-parse-bytesize.c
similarity index 91%
rename from test/test-config-parse-logsize.c
rename to test/test-config-parse-bytesize.c
index 1c64e47..165dab5 100644
--- a/test/test-config-parse-logsize.c
+++ b/test/test-config-parse-bytesize.c
@@ -16,9 +16,11 @@
 	int expected_rc;
 };
 
-void test_config_parse_logsize(void)
+void test_config_parse_bytesize(void)
 {
 	const struct test_parse_size_unit test_data[] = {
+		{ NULL, 0, -1 },
+		{ "", 0, -1 },
 		{ "0", 0, -1 },
 		{ "1", 1, 0 },
 		{ "4k", 4ul * 1024ul, 0 },
@@ -46,7 +48,7 @@
 	int rc;
 
 	for (i = 0; i < num_tests; i++) {
-		rc = config_parse_logsize(test_data[i].test_str, &size);
+		rc = config_parse_bytesize(test_data[i].test_str, &size);
 
 		if (rc == -1 && rc != test_data[i].expected_rc) {
 			warn("[%zu] Str %s expected rc %d, got rc %d\n", i,
@@ -66,6 +68,6 @@
 
 int main(void)
 {
-	test_config_parse_logsize();
+	test_config_parse_bytesize();
 	return EXIT_SUCCESS;
 }