Commit 59970a89 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Jim Harris
Browse files

astyle: enforce braces around single-line statements



Require braces around all conditional statements, e.g.:

    if (cond)
        statement();

becomes:

    if (cond) {
        statement();
    }

This is the style used through most of the SPDK code, but several
exceptions crept in over time.  Add the astyle option to make sure we
are consistent.

Change-Id: I5a71980147fe8dfb471ff42e8bc06db2124a1a7f
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/390914


Reviewed-by: default avatar <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 6bf92c33
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
# Bracket Style
style=kr # K&R brackets
add-braces # Add braces to one-line conditional statements
keep-one-line-blocks # Don't break blocks that are on one line

# Indentation
indent=force-tab=8 # Use tabs for indentation, spaces for minor alignment
+2 −2
Original line number Diff line number Diff line
@@ -45,9 +45,9 @@ static void
spdk_sigusr1(int signo __attribute__((__unused__)))
{
	char *config_str = NULL;
	if (spdk_app_get_running_config(&config_str, "iscsi.conf") < 0)
	if (spdk_app_get_running_config(&config_str, "iscsi.conf") < 0) {
		fprintf(stderr, "Error getting config\n");
	else {
	} else {
		fprintf(stdout, "============================\n");
		fprintf(stdout, " iSCSI target running config\n");
		fprintf(stdout, "=============================\n");
+6 −3
Original line number Diff line number Diff line
@@ -56,14 +56,17 @@ static void usage(void)
static bool
conns_compare(struct spdk_iscsi_conn *first, struct spdk_iscsi_conn *second)
{
	if (first->lcore < second->lcore)
	if (first->lcore < second->lcore) {
		return true;
	}

	if (first->lcore > second->lcore)
	if (first->lcore > second->lcore) {
		return false;
	}

	if (first->id < second->id)
	if (first->id < second->id) {
		return true;
	}

	return false;
}
+2 −1
Original line number Diff line number Diff line
@@ -95,8 +95,9 @@ spdk_get_ifaddr_numa_node(const char *if_addr)
	addr_in.sin_addr.s_addr = inet_addr(if_addr);

	ret = getifaddrs(&ifaddrs);
	if (ret < 0)
	if (ret < 0) {
		return -1;
	}

	for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
		addr = *(struct sockaddr_in *)ifa->ifa_addr;
+13 −7
Original line number Diff line number Diff line
@@ -135,14 +135,16 @@ print_float(const char *arg_string, float arg)
static void
print_arg(bool arg_is_ptr, const char *arg_string, uint64_t arg)
{
	if (arg_string[0] == 0)
	if (arg_string[0] == 0) {
		return;
	}

	if (arg_is_ptr)
	if (arg_is_ptr) {
		print_ptr(arg_string, arg);
	else
	} else {
		print_uint64(arg_string, arg);
	}
}

static void
print_event(struct spdk_trace_entry *e, uint64_t tsc_rate,
@@ -236,19 +238,23 @@ populate_events(struct spdk_trace_history *history)
	if (num_entries == num_entries_filled) {
		first = last = 0;
		for (i = 1; i < num_entries; i++) {
			if (e[i].tsc < e[first].tsc)
			if (e[i].tsc < e[first].tsc) {
				first = i;
			if (e[i].tsc > e[last].tsc)
			}
			if (e[i].tsc > e[last].tsc) {
				last = i;
			}
		}

		first += g_fudge_factor;
		if (first >= num_entries)
		if (first >= num_entries) {
			first -= num_entries;
		}

		last -= g_fudge_factor;
		if (last < 0)
		if (last < 0) {
			last += num_entries;
		}
	} else {
		first = 0;
		last = num_entries_filled - 1;
Loading