Commit 6f5dbefa authored by Nick Mathewson's avatar Nick Mathewson 🥄
Browse files

Normalize space: add one between every control keyword and control clause.


svn:r3003
parent 67dc7baa
...@@ -18,9 +18,9 @@ for $fn (@ARGV) { ...@@ -18,9 +18,9 @@ for $fn (@ARGV) {
print "Space\@EOL:$fn:$.\n"; print "Space\@EOL:$fn:$.\n";
} }
## Warn about control keywords without following space. ## Warn about control keywords without following space.
#if (/\s(?:if|while|for|switch)\(/) { if (/\s(?:if|while|for|switch)\(/) {
# print " KW(:$fn:$.\n"; print " KW(:$fn:$.\n";
#} }
## Warn about multiple empty lines. ## Warn about multiple empty lines.
if ($lastnil && /^$/) { if ($lastnil && /^$/) {
print " DoubleNL:$fn:$.\n"; print " DoubleNL:$fn:$.\n";
......
...@@ -158,7 +158,7 @@ int replace_file(const char *from, const char *to) ...@@ -158,7 +158,7 @@ int replace_file(const char *from, const char *to)
#ifndef MS_WINDOWS #ifndef MS_WINDOWS
return rename(from,to); return rename(from,to);
#else #else
switch(file_status(to)) switch (file_status(to))
{ {
case FN_NOENT: case FN_NOENT:
break; break;
...@@ -318,11 +318,11 @@ int set_max_file_descriptors(unsigned int required_min) { ...@@ -318,11 +318,11 @@ int set_max_file_descriptors(unsigned int required_min) {
strerror(errno)); strerror(errno));
return -1; return -1;
} }
if(required_min > rlim.rlim_max) { if (required_min > rlim.rlim_max) {
log_fn(LOG_WARN,"We need %u file descriptors available, and we're limited to %lu. Please change your ulimit.", required_min, (unsigned long int)rlim.rlim_max); log_fn(LOG_WARN,"We need %u file descriptors available, and we're limited to %lu. Please change your ulimit.", required_min, (unsigned long int)rlim.rlim_max);
return -1; return -1;
} }
if(required_min > rlim.rlim_cur) { if (required_min > rlim.rlim_cur) {
log_fn(LOG_INFO,"Raising max file descriptors from %lu to %lu.", log_fn(LOG_INFO,"Raising max file descriptors from %lu to %lu.",
(unsigned long int)rlim.rlim_cur, (unsigned long int)rlim.rlim_max); (unsigned long int)rlim.rlim_cur, (unsigned long int)rlim.rlim_max);
} }
......
...@@ -104,10 +104,10 @@ void smartlist_add_all(smartlist_t *sl, const smartlist_t *s2) ...@@ -104,10 +104,10 @@ void smartlist_add_all(smartlist_t *sl, const smartlist_t *s2)
*/ */
void smartlist_remove(smartlist_t *sl, void *element) { void smartlist_remove(smartlist_t *sl, void *element) {
int i; int i;
if(element == NULL) if (element == NULL)
return; return;
for(i=0; i < sl->num_used; i++) for (i=0; i < sl->num_used; i++)
if(sl->list[i] == element) { if (sl->list[i] == element) {
sl->list[i] = sl->list[--sl->num_used]; /* swap with the end */ sl->list[i] = sl->list[--sl->num_used]; /* swap with the end */
i--; /* so we process the new i'th element */ i--; /* so we process the new i'th element */
} }
...@@ -117,16 +117,16 @@ void smartlist_remove(smartlist_t *sl, void *element) { ...@@ -117,16 +117,16 @@ void smartlist_remove(smartlist_t *sl, void *element) {
*/ */
int smartlist_isin(const smartlist_t *sl, void *element) { int smartlist_isin(const smartlist_t *sl, void *element) {
int i; int i;
for(i=0; i < sl->num_used; i++) for (i=0; i < sl->num_used; i++)
if(sl->list[i] == element) if (sl->list[i] == element)
return 1; return 1;
return 0; return 0;
} }
int smartlist_string_isin(const smartlist_t *sl, const char *element) { int smartlist_string_isin(const smartlist_t *sl, const char *element) {
int i; int i;
for(i=0; i < sl->num_used; i++) for (i=0; i < sl->num_used; i++)
if(strcmp((const char*)sl->list[i],element)==0) if (strcmp((const char*)sl->list[i],element)==0)
return 1; return 1;
return 0; return 0;
} }
...@@ -135,8 +135,8 @@ int smartlist_string_isin(const smartlist_t *sl, const char *element) { ...@@ -135,8 +135,8 @@ int smartlist_string_isin(const smartlist_t *sl, const char *element) {
*/ */
int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2) { int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2) {
int i; int i;
for(i=0; i < sl2->num_used; i++) for (i=0; i < sl2->num_used; i++)
if(smartlist_isin(sl1, sl2->list[i])) if (smartlist_isin(sl1, sl2->list[i]))
return 1; return 1;
return 0; return 0;
} }
...@@ -146,8 +146,8 @@ int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2) { ...@@ -146,8 +146,8 @@ int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2) {
*/ */
void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2) { void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2) {
int i; int i;
for(i=0; i < sl1->num_used; i++) for (i=0; i < sl1->num_used; i++)
if(!smartlist_isin(sl2, sl1->list[i])) { if (!smartlist_isin(sl2, sl1->list[i])) {
sl1->list[i] = sl1->list[--sl1->num_used]; /* swap with the end */ sl1->list[i] = sl1->list[--sl1->num_used]; /* swap with the end */
i--; /* so we process the new i'th element */ i--; /* so we process the new i'th element */
} }
...@@ -158,7 +158,7 @@ void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2) { ...@@ -158,7 +158,7 @@ void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2) {
*/ */
void smartlist_subtract(smartlist_t *sl1, const smartlist_t *sl2) { void smartlist_subtract(smartlist_t *sl1, const smartlist_t *sl2) {
int i; int i;
for(i=0; i < sl2->num_used; i++) for (i=0; i < sl2->num_used; i++)
smartlist_remove(sl1, sl2->list[i]); smartlist_remove(sl1, sl2->list[i]);
} }
...@@ -544,7 +544,7 @@ void strmap_foreach(strmap_t *map, ...@@ -544,7 +544,7 @@ void strmap_foreach(strmap_t *map,
* iter = strmap_iter_next_rmv(iter); * iter = strmap_iter_next_rmv(iter);
* free(val); * free(val);
* } else { * } else {
* for(;*cp;cp++) *cp = toupper(*cp); * for (;*cp;cp++) *cp = toupper(*cp);
* iter = strmap_iter_next(iter); * iter = strmap_iter_next(iter);
* } * }
* } * }
......
...@@ -60,7 +60,7 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join, ...@@ -60,7 +60,7 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join,
do { \ do { \
int var ## _sl_idx, var ## _sl_len=smartlist_len(sl); \ int var ## _sl_idx, var ## _sl_len=smartlist_len(sl); \
type var; \ type var; \
for(var ## _sl_idx = 0; var ## _sl_idx < var ## _sl_len; \ for (var ## _sl_idx = 0; var ## _sl_idx < var ## _sl_len; \
++var ## _sl_idx) { \ ++var ## _sl_idx) { \
var = smartlist_get((sl),var ## _sl_idx); \ var = smartlist_get((sl),var ## _sl_idx); \
cmd; \ cmd; \
......
...@@ -103,7 +103,7 @@ DH *_crypto_dh_env_get_dh(crypto_dh_env_t *dh); ...@@ -103,7 +103,7 @@ DH *_crypto_dh_env_get_dh(crypto_dh_env_t *dh);
*/ */
static INLINE int static INLINE int
crypto_get_rsa_padding_overhead(int padding) { crypto_get_rsa_padding_overhead(int padding) {
switch(padding) switch (padding)
{ {
case RSA_NO_PADDING: return 0; case RSA_NO_PADDING: return 0;
case RSA_PKCS1_OAEP_PADDING: return 42; case RSA_PKCS1_OAEP_PADDING: return 42;
...@@ -116,7 +116,7 @@ crypto_get_rsa_padding_overhead(int padding) { ...@@ -116,7 +116,7 @@ crypto_get_rsa_padding_overhead(int padding) {
*/ */
static INLINE int static INLINE int
crypto_get_rsa_padding(int padding) { crypto_get_rsa_padding(int padding) {
switch(padding) switch (padding)
{ {
case PK_NO_PADDING: return RSA_NO_PADDING; case PK_NO_PADDING: return RSA_NO_PADDING;
case PK_PKCS1_PADDING: return RSA_PKCS1_PADDING; case PK_PKCS1_PADDING: return RSA_PKCS1_PADDING;
...@@ -238,7 +238,7 @@ void crypto_free_pk_env(crypto_pk_env_t *env) ...@@ -238,7 +238,7 @@ void crypto_free_pk_env(crypto_pk_env_t *env)
{ {
tor_assert(env); tor_assert(env);
if(--env->refs > 0) if (--env->refs > 0)
return; return;
if (env->key) if (env->key)
...@@ -398,7 +398,7 @@ int crypto_pk_write_public_key_to_string(crypto_pk_env_t *env, char **dest, size ...@@ -398,7 +398,7 @@ int crypto_pk_write_public_key_to_string(crypto_pk_env_t *env, char **dest, size
/* Now you can treat b as if it were a file. Just use the /* Now you can treat b as if it were a file. Just use the
* PEM_*_bio_* functions instead of the non-bio variants. * PEM_*_bio_* functions instead of the non-bio variants.
*/ */
if(!PEM_write_bio_RSAPublicKey(b, env->key)) { if (!PEM_write_bio_RSAPublicKey(b, env->key)) {
crypto_log_errors(LOG_WARN, "writing public key to string"); crypto_log_errors(LOG_WARN, "writing public key to string");
return -1; return -1;
} }
...@@ -435,7 +435,7 @@ int crypto_pk_read_public_key_from_string(crypto_pk_env_t *env, const char *src, ...@@ -435,7 +435,7 @@ int crypto_pk_read_public_key_from_string(crypto_pk_env_t *env, const char *src,
RSA_free(env->key); RSA_free(env->key);
env->key = PEM_read_bio_RSAPublicKey(b, NULL, NULL, NULL); env->key = PEM_read_bio_RSAPublicKey(b, NULL, NULL, NULL);
BIO_free(b); BIO_free(b);
if(!env->key) { if (!env->key) {
crypto_log_errors(LOG_WARN, "reading public key from string"); crypto_log_errors(LOG_WARN, "reading public key from string");
return -1; return -1;
} }
...@@ -1346,7 +1346,7 @@ int crypto_dh_compute_secret(crypto_dh_env_t *dh, ...@@ -1346,7 +1346,7 @@ int crypto_dh_compute_secret(crypto_dh_env_t *dh,
goto error; goto error;
secret_tmp = tor_malloc(crypto_dh_get_bytes(dh)+1); secret_tmp = tor_malloc(crypto_dh_get_bytes(dh)+1);
result = DH_compute_key(secret_tmp, pubkey_bn, dh->dh); result = DH_compute_key(secret_tmp, pubkey_bn, dh->dh);
if(result < 0) { if (result < 0) {
log_fn(LOG_WARN,"DH_compute_key() failed."); log_fn(LOG_WARN,"DH_compute_key() failed.");
goto error; goto error;
} }
...@@ -1368,7 +1368,7 @@ int crypto_dh_compute_secret(crypto_dh_env_t *dh, ...@@ -1368,7 +1368,7 @@ int crypto_dh_compute_secret(crypto_dh_env_t *dh,
if (pubkey_bn) if (pubkey_bn)
BN_free(pubkey_bn); BN_free(pubkey_bn);
tor_free(secret_tmp); tor_free(secret_tmp);
if(result < 0) if (result < 0)
return result; return result;
else else
return secret_len; return secret_len;
...@@ -1486,7 +1486,7 @@ int crypto_pseudo_rand_int(unsigned int max) { ...@@ -1486,7 +1486,7 @@ int crypto_pseudo_rand_int(unsigned int max) {
* range. * range.
*/ */
cutoff = UINT_MAX - (UINT_MAX%max); cutoff = UINT_MAX - (UINT_MAX%max);
while(1) { while (1) {
crypto_pseudo_rand((unsigned char*) &val, sizeof(val)); crypto_pseudo_rand((unsigned char*) &val, sizeof(val));
if (val < cutoff) if (val < cutoff)
return val % max; return val % max;
...@@ -1498,7 +1498,7 @@ int crypto_pseudo_rand_int(unsigned int max) { ...@@ -1498,7 +1498,7 @@ int crypto_pseudo_rand_int(unsigned int max) {
void *smartlist_choose(const smartlist_t *sl) { void *smartlist_choose(const smartlist_t *sl) {
size_t len; size_t len;
len = smartlist_len(sl); len = smartlist_len(sl);
if(len) if (len)
return smartlist_get(sl,crypto_pseudo_rand_int(len)); return smartlist_get(sl,crypto_pseudo_rand_int(len));
return NULL; /* no elements to choose from */ return NULL; /* no elements to choose from */
} }
......
...@@ -34,7 +34,7 @@ typedef struct logfile_t { ...@@ -34,7 +34,7 @@ typedef struct logfile_t {
/** Helper: map a log severity to descriptive string. */ /** Helper: map a log severity to descriptive string. */
static INLINE const char *sev_to_string(int severity) { static INLINE const char *sev_to_string(int severity) {
switch(severity) { switch (severity) {
case LOG_DEBUG: return "debug"; case LOG_DEBUG: return "debug";
case LOG_INFO: return "info"; case LOG_INFO: return "info";
case LOG_NOTICE: return "notice"; case LOG_NOTICE: return "notice";
...@@ -136,7 +136,7 @@ static INLINE char *format_msg(char *buf, size_t buf_len, ...@@ -136,7 +136,7 @@ static INLINE char *format_msg(char *buf, size_t buf_len,
} }
r = tor_vsnprintf(buf+n,buf_len-n,format,ap); r = tor_vsnprintf(buf+n,buf_len-n,format,ap);
if(r < 0) { if (r < 0) {
n = buf_len-2; n = buf_len-2;
strlcpy(buf+buf_len-TRUNCATED_STR_LEN-1, TRUNCATED_STR, strlcpy(buf+buf_len-TRUNCATED_STR_LEN-1, TRUNCATED_STR,
buf_len-(buf_len-TRUNCATED_STR_LEN-1)); buf_len-(buf_len-TRUNCATED_STR_LEN-1));
...@@ -162,7 +162,7 @@ logv(int severity, const char *funcname, const char *format, va_list ap) ...@@ -162,7 +162,7 @@ logv(int severity, const char *funcname, const char *format, va_list ap)
assert(format); assert(format);
lf = logfiles; lf = logfiles;
while(lf) { while (lf) {
if (severity > lf->loglevel || severity < lf->max_loglevel) { if (severity > lf->loglevel || severity < lf->max_loglevel) {
lf = lf->next; lf = lf->next;
continue; continue;
...@@ -188,7 +188,7 @@ logv(int severity, const char *funcname, const char *format, va_list ap) ...@@ -188,7 +188,7 @@ logv(int severity, const char *funcname, const char *format, va_list ap)
lf = lf->next; lf = lf->next;
continue; continue;
} }
if(fputs(buf, lf->file) == EOF || if (fputs(buf, lf->file) == EOF ||
fflush(lf->file) == EOF) { /* error */ fflush(lf->file) == EOF) { /* error */
/* don't log the error! Blow away this log entry and continue. */ /* don't log the error! Blow away this log entry and continue. */
logfile_t *victim = lf; logfile_t *victim = lf;
...@@ -234,7 +234,7 @@ void _log_fn(int severity, const char *format, ...) ...@@ -234,7 +234,7 @@ void _log_fn(int severity, const char *format, ...)
void close_logs() void close_logs()
{ {
logfile_t *victim; logfile_t *victim;
while(logfiles) { while (logfiles) {
victim = logfiles; victim = logfiles;
logfiles = logfiles->next; logfiles = logfiles->next;
close_log(victim); close_log(victim);
...@@ -247,7 +247,7 @@ void close_logs() ...@@ -247,7 +247,7 @@ void close_logs()
void reset_logs() void reset_logs()
{ {
logfile_t *lf = logfiles; logfile_t *lf = logfiles;
while(lf) { while (lf) {
if (reset_log(lf)) { if (reset_log(lf)) {
/* error. don't log it. delete the log entry and continue. */ /* error. don't log it. delete the log entry and continue. */
logfile_t *victim = lf; logfile_t *victim = lf;
...@@ -266,10 +266,10 @@ void reset_logs() ...@@ -266,10 +266,10 @@ void reset_logs()
*/ */
static void delete_log(logfile_t *victim) { static void delete_log(logfile_t *victim) {
logfile_t *tmpl; logfile_t *tmpl;
if(victim == logfiles) if (victim == logfiles)
logfiles = victim->next; logfiles = victim->next;
else { else {
for(tmpl = logfiles; tmpl && tmpl->next != victim; tmpl=tmpl->next) ; for (tmpl = logfiles; tmpl && tmpl->next != victim; tmpl=tmpl->next) ;
tor_assert(tmpl); tor_assert(tmpl);
tor_assert(tmpl->next == victim); tor_assert(tmpl->next == victim);
tmpl->next = victim->next; tmpl->next = victim->next;
......
...@@ -90,7 +90,7 @@ void _log_fn(int severity, const char *funcname, const char *format, ...) ...@@ -90,7 +90,7 @@ void _log_fn(int severity, const char *funcname, const char *format, ...)
extern const char *_log_fn_function_name; extern const char *_log_fn_function_name;
void _log_fn(int severity, const char *format, ...); void _log_fn(int severity, const char *format, ...);
/* We abuse the comma operator here, since we can't use the standard /* We abuse the comma operator here, since we can't use the standard
* do {...} while(0) trick to wrap this macro, since the macro can't take * do {...} while (0) trick to wrap this macro, since the macro can't take
* arguments. */ * arguments. */
#define log_fn (_log_fn_function_name=__FUNCTION__),_log_fn #define log_fn (_log_fn_function_name=__FUNCTION__),_log_fn
#endif #endif
......
...@@ -36,7 +36,7 @@ extern int have_failed; ...@@ -36,7 +36,7 @@ extern int have_failed;
#define test_assert(expr) \ #define test_assert(expr) \
STMT_BEGIN \ STMT_BEGIN \
if(expr) { printf("."); fflush(stdout); } else { \ if (expr) { printf("."); fflush(stdout); } else { \
have_failed = 1; \ have_failed = 1; \
printf("\nFile %s: line %d (%s): assertion failed: (%s)\n", \ printf("\nFile %s: line %d (%s): assertion failed: (%s)\n", \
__FILE__, \ __FILE__, \
...@@ -49,7 +49,7 @@ extern int have_failed; ...@@ -49,7 +49,7 @@ extern int have_failed;
#define test_eq(expr1, expr2) \ #define test_eq(expr1, expr2) \
STMT_BEGIN \ STMT_BEGIN \
long v1=(long)(expr1), v2=(long)(expr2); \ long v1=(long)(expr1), v2=(long)(expr2); \
if(v1==v2) { printf("."); fflush(stdout); } else { \ if (v1==v2) { printf("."); fflush(stdout); } else { \
have_failed = 1; \ have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\ printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\
" (%ld != %ld)\n", \ " (%ld != %ld)\n", \
...@@ -64,7 +64,7 @@ extern int have_failed; ...@@ -64,7 +64,7 @@ extern int have_failed;
#define test_neq(expr1, expr2) \ #define test_neq(expr1, expr2) \
STMT_BEGIN \ STMT_BEGIN \
long v1=(long)(expr1), v2=(long)(expr2); \ long v1=(long)(expr1), v2=(long)(expr2); \
if(v1!=v2) { printf("."); fflush(stdout); } else { \ if (v1!=v2) { printf("."); fflush(stdout); } else { \
have_failed = 1; \ have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\ printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\
" (%ld == %ld)\n", \ " (%ld == %ld)\n", \
...@@ -79,7 +79,7 @@ extern int have_failed; ...@@ -79,7 +79,7 @@ extern int have_failed;
#define test_streq(expr1, expr2) \ #define test_streq(expr1, expr2) \
STMT_BEGIN \ STMT_BEGIN \
const char *v1=(expr1), *v2=(expr2); \ const char *v1=(expr1), *v2=(expr2); \
if(!strcmp(v1,v2)) { printf("."); fflush(stdout); } else { \ if (!strcmp(v1,v2)) { printf("."); fflush(stdout); } else { \
have_failed = 1; \ have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\ printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\
" (\"%s\" != \"%s\")\n", \ " (\"%s\" != \"%s\")\n", \
...@@ -94,7 +94,7 @@ extern int have_failed; ...@@ -94,7 +94,7 @@ extern int have_failed;
#define test_strneq(expr1, expr2) \ #define test_strneq(expr1, expr2) \
STMT_BEGIN \ STMT_BEGIN \
const char *v1=(expr1), *v2=(expr2); \ const char *v1=(expr1), *v2=(expr2); \
if(strcmp(v1,v2)) { printf("."); fflush(stdout); } else { \ if (strcmp(v1,v2)) { printf("."); fflush(stdout); } else { \
have_failed = 1; \ have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\ printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\
" (\"%s\" == \"%s\")\n", \ " (\"%s\" == \"%s\")\n", \
...@@ -109,7 +109,7 @@ extern int have_failed; ...@@ -109,7 +109,7 @@ extern int have_failed;
#define test_memeq(expr1, expr2, len) \ #define test_memeq(expr1, expr2, len) \
STMT_BEGIN \ STMT_BEGIN \
const void *v1=(expr1), *v2=(expr2); \ const void *v1=(expr1), *v2=(expr2); \
if(!memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else { \ if (!memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else {\
have_failed = 1; \ have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n", \ printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n", \
__FILE__, \ __FILE__, \
...@@ -122,7 +122,7 @@ extern int have_failed; ...@@ -122,7 +122,7 @@ extern int have_failed;
#define test_memneq(expr1, expr2, len) \ #define test_memneq(expr1, expr2, len) \
STMT_BEGIN \ STMT_BEGIN \
void *v1=(expr1), *v2=(expr2); \ void *v1=(expr1), *v2=(expr2); \
if(memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else { \ if (memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else {\
have_failed = 1; \ have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n", \ printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n", \
__FILE__, \ __FILE__, \
......
...@@ -176,7 +176,7 @@ tor_gzip_uncompress(char **out, size_t *out_len, ...@@ -176,7 +176,7 @@ tor_gzip_uncompress(char **out, size_t *out_len,
stream->avail_out = out_size; stream->avail_out = out_size;
while (1) { while (1) {
switch(inflate(stream, Z_FINISH)) switch (inflate(stream, Z_FINISH))
{ {
case Z_STREAM_END: case Z_STREAM_END:
goto done; goto done;
......
...@@ -466,7 +466,7 @@ tor_tls_write(tor_tls *tls, char *cp, size_t n) ...@@ -466,7 +466,7 @@ tor_tls_write(tor_tls *tls, char *cp, size_t n)
tor_assert(tls->state == TOR_TLS_ST_OPEN); tor_assert(tls->state == TOR_TLS_ST_OPEN);
if (n == 0) if (n == 0)
return 0; return 0;
if(tls->wantwrite_n) { if (tls->wantwrite_n) {
/* if WANTWRITE last time, we must use the _same_ n as before */ /* if WANTWRITE last time, we must use the _same_ n as before */
tor_assert(n >= tls->wantwrite_n); tor_assert(n >= tls->wantwrite_n);
log_fn(LOG_DEBUG,"resuming pending-write, (%d to flush, reusing %d)", log_fn(LOG_DEBUG,"resuming pending-write, (%d to flush, reusing %d)",
......
...@@ -108,7 +108,7 @@ void *tor_malloc(size_t size) { ...@@ -108,7 +108,7 @@ void *tor_malloc(size_t size) {
} }
result = malloc(size); result = malloc(size);
if(!result) { if (!result) {
log_fn(LOG_ERR, "Out of memory. Dying."); log_fn(LOG_ERR, "Out of memory. Dying.");
exit(1); exit(1);
} }
...@@ -150,7 +150,7 @@ char *tor_strdup(const char *s) { ...@@ -150,7 +150,7 @@ char *tor_strdup(const char *s) {
tor_assert(s); tor_assert(s);
dup = strdup(s); dup = strdup(s);
if(!dup) { if (!dup) {
log_fn(LOG_ERR,"Out of memory. Dying."); log_fn(LOG_ERR,"Out of memory. Dying.");
exit(1); exit(1);
} }
...@@ -221,7 +221,7 @@ int tor_strpartition(char *dest, size_t dest_len, ...@@ -221,7 +221,7 @@ int tor_strpartition(char *dest, size_t dest_len,
len_ins = strlen(insert); len_ins = strlen(insert);
len_out = len_in + (len_in/n)*len_ins; len_out = len_in + (len_in/n)*len_ins;
is_even = (len_in%n) == 0; is_even = (len_in%n) == 0;
switch(rule) switch (rule)
{ {
case ALWAYS_TERMINATE: case ALWAYS_TERMINATE:
if (!is_even) len_out += len_ins; if (!is_even) len_out += len_ins;
...@@ -236,7 +236,7 @@ int tor_strpartition(char *dest, size_t dest_len, ...@@ -236,7 +236,7 @@ int tor_strpartition(char *dest, size_t dest_len,
return -1; return -1;
destp = dest; destp = dest;
remaining = len_in; remaining = len_in;
while(remaining) { while (remaining) {
strncpy(destp, s, n); strncpy(destp, s, n);
remaining -= n; remaining -= n;
if (remaining < 0) { if (remaining < 0) {
...@@ -306,13 +306,13 @@ int strcmpend(const char *s1, const char *s2) ...@@ -306,13 +306,13 @@ int strcmpend(const char *s1, const char *s2)
const char *eat_whitespace(const char *s) { const char *eat_whitespace(const char *s) {
tor_assert(s); tor_assert(s);
while(isspace((int)*s) || *s == '#') { while (isspace((int)*s) || *s == '#') {
while(isspace((int)*s)) while (isspace((int)*s))
s++; s++;
if(*s == '#') { /* read to a \n or \0 */ if (*s == '#') { /* read to a \n or \0 */
while(*s && *s != '\n') while (*s && *s != '\n')
s++; s++;
if(!*s) if (!*s)
return s; return s;
} }
} }
...@@ -322,7 +322,7 @@ const char *eat_whitespace(const char *s) { ...@@ -322,7 +322,7 @@ const char *eat_whitespace(const char *s) {
/** Return a pointer to the first char of s that is not a space or a tab, /** Return a pointer to the first char of s that is not a space or a tab,
* or to the terminating NUL if no such character exists. */ * or to the terminating NUL if no such character exists. */
const char *eat_whitespace_no_nl(const char *s) { const char *eat_whitespace_no_nl(const char *s) {
while(*s == ' ' || *s == '\t') while (*s == ' ' || *s == '\t')
++s; ++s;
return s; return s;
} }
...@@ -333,7 +333,7 @@ const char *eat_whitespace_no_nl(const char *s) { ...@@ -333,7 +333,7 @@ const char *eat_whitespace_no_nl(const char *s) {
const char *find_whitespace(const <