CRAS: Format cras_system_state

Reformat codes with the .clang-format we just introduced.
To format whole files provided in-place:
clang-format -i -style=file [<file> ...]

BUG=chromium:950858
TEST=Add directory to check_format_error and run
FEATURES="test" USE=asan emerge-${BOARD} -v media-sound/adhd

Change-Id: Id214a7cf38db74f457ffbf427bf6abbc555c5b29
Reviewed-on: https://chromium-review.googlesource.com/1669346
Tested-by: En-Shuo Hsu <enshuo@google.com>
Commit-Ready: En-Shuo Hsu <enshuo@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
diff --git a/cras/src/server/cras_system_state.c b/cras/src/server/cras_system_state.c
index 803de20..7aa3367 100644
--- a/cras/src/server/cras_system_state.c
+++ b/cras/src/server/cras_system_state.c
@@ -62,13 +62,12 @@
 	pthread_mutex_t update_lock;
 	struct cras_tm *tm;
 	/* Select loop callback registration. */
-	int (*fd_add)(int fd, void (*cb)(void *data),
-		      void *cb_data, void *select_data);
+	int (*fd_add)(int fd, void (*cb)(void *data), void *cb_data,
+		      void *select_data);
 	void (*fd_rm)(int fd, void *select_data);
 	void *select_data;
-	int (*add_task)(void (*callback)(void *data),
-					 void *callback_data,
-					 void *task_data);
+	int (*add_task)(void (*callback)(void *data), void *callback_data,
+			void *task_data);
 	void *task_data;
 	struct cras_audio_thread_snapshot_buffer snapshot_buffer;
 	pthread_t main_thread_tid;
@@ -78,21 +77,19 @@
  * Exported Interface.
  */
 
-void cras_system_state_init(const char *device_config_dir,
-                            const char *shm_name,
-                            int rw_shm_fd,
-                            int ro_shm_fd,
-                            struct cras_server_state *exp_state,
-                            size_t exp_state_size)
+void cras_system_state_init(const char *device_config_dir, const char *shm_name,
+			    int rw_shm_fd, int ro_shm_fd,
+			    struct cras_server_state *exp_state,
+			    size_t exp_state_size)
 {
 	struct cras_board_config board_config;
 	int rc;
 
-        assert(sizeof(*exp_state) == exp_state_size);
+	assert(sizeof(*exp_state) == exp_state_size);
 	state.shm_size = sizeof(*exp_state);
 
-        strncpy(state.shm_name, shm_name, sizeof(state.shm_name));
-        state.shm_name[sizeof(state.shm_name) - 1] = '\0';
+	strncpy(state.shm_name, shm_name, sizeof(state.shm_name));
+	state.shm_name[sizeof(state.shm_name) - 1] = '\0';
 	state.shm_fd = rw_shm_fd;
 	state.shm_fd_ro = ro_shm_fd;
 
@@ -117,10 +114,8 @@
 	exp_state->num_streams_attached = 0;
 	exp_state->default_output_buffer_size =
 		board_config.default_output_buffer_size;
-	exp_state->aec_supported =
-		board_config.aec_supported;
-	exp_state->aec_group_id =
-		board_config.aec_group_id;
+	exp_state->aec_supported = board_config.aec_supported;
+	exp_state->aec_group_id = board_config.aec_group_id;
 	exp_state->bt_wbs_enabled = 0;
 
 	if ((rc = pthread_mutex_init(&state.update_lock, 0) != 0)) {
@@ -387,17 +382,15 @@
 
 	card_index = alsa_card_info->card_index;
 
-	DL_FOREACH(state.cards, card) {
+	DL_FOREACH (state.cards, card) {
 		if (card_index == cras_alsa_card_get_index(card->card))
 			return -EEXIST;
 	}
 	alsa_card = cras_alsa_card_create(
-			alsa_card_info,
-			state.device_config_dir,
-			state.device_blacklist,
-			(alsa_card_info->card_type == ALSA_CARD_TYPE_INTERNAL)
-				? state.internal_ucm_suffix
-				: NULL);
+		alsa_card_info, state.device_config_dir, state.device_blacklist,
+		(alsa_card_info->card_type == ALSA_CARD_TYPE_INTERNAL) ?
+			state.internal_ucm_suffix :
+			NULL);
 	if (alsa_card == NULL)
 		return -ENOMEM;
 	card = calloc(1, sizeof(*card));
@@ -412,7 +405,7 @@
 {
 	struct card_list *card;
 
-	DL_FOREACH(state.cards, card) {
+	DL_FOREACH (state.cards, card) {
 		if (alsa_card_index == cras_alsa_card_get_index(card->card))
 			break;
 	}
@@ -428,18 +421,16 @@
 {
 	struct card_list *card;
 
-	DL_FOREACH(state.cards, card)
+	DL_FOREACH (state.cards, card)
 		if (alsa_card_index == cras_alsa_card_get_index(card->card))
 			return 1;
 	return 0;
 }
 
-int cras_system_set_select_handler(int (*add)(int fd,
-					      void (*callback)(void *data),
-					      void *callback_data,
-					      void *select_data),
-				   void (*rm)(int fd, void *select_data),
-				   void *select_data)
+int cras_system_set_select_handler(
+	int (*add)(int fd, void (*callback)(void *data), void *callback_data,
+		   void *select_data),
+	void (*rm)(int fd, void *select_data), void *select_data)
 {
 	if (state.fd_add != NULL || state.fd_rm != NULL)
 		return -EEXIST;
@@ -449,14 +440,12 @@
 	return 0;
 }
 
-int cras_system_add_select_fd(int fd,
-			      void (*callback)(void *data),
+int cras_system_add_select_fd(int fd, void (*callback)(void *data),
 			      void *callback_data)
 {
 	if (state.fd_add == NULL)
 		return -EINVAL;
-	return state.fd_add(fd, callback, callback_data,
-			    state.select_data);
+	return state.fd_add(fd, callback, callback_data, state.select_data);
 }
 
 int cras_system_set_add_task_handler(int (*add_task)(void (*cb)(void *data),
@@ -507,13 +496,12 @@
 	struct cras_server_state *s;
 	unsigned i, sum;
 
-
 	s = cras_system_state_update_begin();
 	if (!s)
 		return;
 
 	sum = 0;
-	for (i=0; i < CRAS_NUM_DIRECTIONS; i++)
+	for (i = 0; i < CRAS_NUM_DIRECTIONS; i++)
 		sum += s->num_active_streams[i];
 
 	/* Set the last active time when removing the final stream. */
@@ -531,7 +519,7 @@
 {
 	unsigned i, sum;
 	sum = 0;
-	for (i=0; i < CRAS_NUM_DIRECTIONS; i++)
+	for (i = 0; i < CRAS_NUM_DIRECTIONS; i++)
 		sum += state.exp_state->num_active_streams[i];
 	return sum;
 }
@@ -613,20 +601,17 @@
 	return state.tm;
 }
 
-
 void cras_system_state_dump_snapshots()
 {
 	memcpy(&state.exp_state->snapshot_buffer, &state.snapshot_buffer,
-			sizeof(struct cras_audio_thread_snapshot_buffer));
+	       sizeof(struct cras_audio_thread_snapshot_buffer));
 }
 
-void cras_system_state_add_snapshot(
-	struct cras_audio_thread_snapshot *snapshot)
+void cras_system_state_add_snapshot(struct cras_audio_thread_snapshot *snapshot)
 {
 	state.snapshot_buffer.snapshots[state.snapshot_buffer.pos++] =
-			(*snapshot);
-	state.snapshot_buffer.pos %=
-		CRAS_MAX_AUDIO_THREAD_SNAPSHOTS;
+		(*snapshot);
+	state.snapshot_buffer.pos %= CRAS_MAX_AUDIO_THREAD_SNAPSHOTS;
 }
 
 int cras_system_state_in_main_thread()
diff --git a/cras/src/server/cras_system_state.h b/cras/src/server/cras_system_state.h
index fb6cc3d..270e54c 100644
--- a/cras/src/server/cras_system_state.h
+++ b/cras/src/server/cras_system_state.h
@@ -38,12 +38,10 @@
  *    exp_state - Shared memory region for storing state.
  *    exp_state_size - Size of |exp_state|.
  */
-void cras_system_state_init(const char *device_config_dir,
-                            const char *shm_name,
-                            int rw_shm_fd,
-                            int ro_shm_fd,
-                            struct cras_server_state *exp_state,
-                            size_t exp_state_size);
+void cras_system_state_init(const char *device_config_dir, const char *shm_name,
+			    int rw_shm_fd, int ro_shm_fd,
+			    struct cras_server_state *exp_state,
+			    size_t exp_state_size);
 void cras_system_state_deinit();
 
 /* Sets the suffix string to control which UCM config fo load. */
@@ -175,12 +173,10 @@
  * Returns:
  *    0 on success, or -EBUSY if there is already a registered handler.
  */
-int cras_system_set_select_handler(int (*add)(int fd,
-					      void (*callback)(void *data),
-					      void *callback_data,
-					      void *select_data),
-				  void (*rm)(int fd, void *select_data),
-				  void *select_data);
+int cras_system_set_select_handler(
+	int (*add)(int fd, void (*callback)(void *data), void *callback_data,
+		   void *select_data),
+	void (*rm)(int fd, void *select_data), void *select_data);
 
 /* Adds the fd and callback pair.  When select indicates that fd is readable,
  * the callback will be called.
@@ -191,8 +187,7 @@
  * Returns:
  *    0 on success or a negative error code on failure.
  */
-int cras_system_add_select_fd(int fd,
-			      void (*callback)(void *data),
+int cras_system_add_select_fd(int fd, void (*callback)(void *data),
 			      void *callback_data);
 
 /* Removes the fd from the list of fds that are passed to select.