Re-indent resolver code with clang-format
clang-format --style file -i *.{c,h}
Test: code does not compile yet
Change-Id: I8c509de4f8558b2dd74668cf40bb73c4316dc5ad
diff --git a/resolv/res_state.c b/resolv/res_state.c
index 94124ff..be349fb 100644
--- a/resolv/res_state.c
+++ b/resolv/res_state.c
@@ -25,40 +25,39 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#include <sys/types.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <netdb.h>
-#include "resolv_private.h"
-#include "resolv_cache.h"
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
-
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include "resolv_cache.h"
+#include "resolv_private.h"
/* Set to 1 to enable debug traces */
#define DEBUG 0
#if DEBUG
-# include <async_safe/log.h>
-# include <unistd.h> /* for gettid() */
-# define D(...) async_safe_format_log(ANDROID_LOG_DEBUG,"libc", __VA_ARGS__)
+#include <async_safe/log.h>
+#include <unistd.h> /* for gettid() */
+#define D(...) async_safe_format_log(ANDROID_LOG_DEBUG, "libc", __VA_ARGS__)
#else
-# define D(...) do{}while(0)
+#define D(...) \
+ do { \
+ } while (0)
#endif
typedef struct {
- int _h_errno;
+ int _h_errno;
// TODO: Have one __res_state per network so we don't have to repopulate frequently.
- struct __res_state _nres[1];
- struct res_static _rstatic[1];
+ struct __res_state _nres[1];
+ struct res_static _rstatic[1];
} _res_thread;
-static _res_thread*
-_res_thread_alloc(void)
-{
- _res_thread* rt = calloc(1, sizeof(*rt));
+static _res_thread* _res_thread_alloc(void) {
+ _res_thread* rt = calloc(1, sizeof(*rt));
if (rt) {
rt->_h_errno = 0;
@@ -67,24 +66,20 @@
return rt;
}
-static void
-_res_static_done( res_static rs )
-{
+static void _res_static_done(res_static rs) {
/* fortunately, there is nothing to do here, since the
* points in h_addr_ptrs and host_aliases should all
* point to 'hostbuf'
*/
- if (rs->hostf) { /* should not happen in theory, but just be safe */
+ if (rs->hostf) { /* should not happen in theory, but just be safe */
fclose(rs->hostf);
rs->hostf = NULL;
}
free(rs->servent.s_aliases);
}
-static void
-_res_thread_free( void* _rt )
-{
- _res_thread* rt = _rt;
+static void _res_thread_free(void* _rt) {
+ _res_thread* rt = _rt;
D("%s: rt=%p for thread=%d", __FUNCTION__, rt, gettid());
@@ -99,11 +94,9 @@
pthread_key_create(&_res_key, _res_thread_free);
}
-static _res_thread*
-_res_thread_get(void)
-{
- _res_thread* rt;
- rt = pthread_getspecific( _res_key );
+static _res_thread* _res_thread_get(void) {
+ _res_thread* rt;
+ rt = pthread_getspecific(_res_key);
if (rt != NULL) {
return rt;
@@ -115,21 +108,19 @@
if (rt == NULL) {
return NULL;
}
- pthread_setspecific( _res_key, rt );
- D("%s: tid=%d Created new DNS state rt=%p",
- __FUNCTION__, gettid(), rt);
+ pthread_setspecific(_res_key, rt);
+ D("%s: tid=%d Created new DNS state rt=%p", __FUNCTION__, gettid(), rt);
/* Reset the state, note that res_ninit() can now properly reset
* an existing state without leaking memory.
*/
- D("%s: tid=%d, rt=%p, setting DNS state (options RES_INIT=%d)",
- __FUNCTION__, gettid(), rt, (rt->_nres->options & RES_INIT) != 0);
- if ( res_ninit( rt->_nres ) < 0 ) {
+ D("%s: tid=%d, rt=%p, setting DNS state (options RES_INIT=%d)", __FUNCTION__, gettid(), rt,
+ (rt->_nres->options & RES_INIT) != 0);
+ if (res_ninit(rt->_nres) < 0) {
/* This should not happen */
- D("%s: tid=%d rt=%p, woot, res_ninit() returned < 0",
- __FUNCTION__, gettid(), rt);
+ D("%s: tid=%d rt=%p, woot, res_ninit() returned < 0", __FUNCTION__, gettid(), rt);
_res_thread_free(rt);
- pthread_setspecific( _res_key, NULL );
+ pthread_setspecific(_res_key, NULL);
return NULL;
}
return rt;
@@ -154,33 +145,25 @@
}
#endif
-int*
-__get_h_errno(void)
-{
- _res_thread* rt = _res_thread_get();
- static int panic = NETDB_INTERNAL;
+int* __get_h_errno(void) {
+ _res_thread* rt = _res_thread_get();
+ static int panic = NETDB_INTERNAL;
return rt ? &rt->_h_errno : &panic;
}
-res_state
-__res_get_state(void)
-{
- _res_thread* rt = _res_thread_get();
+res_state __res_get_state(void) {
+ _res_thread* rt = _res_thread_get();
return rt ? rt->_nres : NULL;
}
-void
-__res_put_state(res_state res __unused)
-{
+void __res_put_state(res_state res __unused) {
/* nothing to do */
}
-res_static
-__res_get_static(void)
-{
- _res_thread* rt = _res_thread_get();
+res_static __res_get_static(void) {
+ _res_thread* rt = _res_thread_get();
return rt ? rt->_rstatic : NULL;
}