[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Normalize space: add one between every control keyword and ...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] Normalize space: add one between every control keyword and ...
- From: nickm@seul.org (Nick Mathewson)
- Date: Sun, 28 Nov 2004 04:05:50 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sun, 28 Nov 2004 04:14:18 -0500
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/tor/src/common
In directory moria.mit.edu:/tmp/cvs-serv11426/src/common
Modified Files:
compat.c container.c container.h crypto.c log.c log.h test.h
torgzip.c tortls.c util.c util.h
Log Message:
Normalize space: add one between every control keyword and control clause.
Index: compat.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/compat.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- compat.c 28 Nov 2004 05:57:18 -0000 1.14
+++ compat.c 28 Nov 2004 09:05:45 -0000 1.15
@@ -158,7 +158,7 @@
#ifndef MS_WINDOWS
return rename(from,to);
#else
- switch(file_status(to))
+ switch (file_status(to))
{
case FN_NOENT:
break;
@@ -318,11 +318,11 @@
strerror(errno));
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);
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.",
(unsigned long int)rlim.rlim_cur, (unsigned long int)rlim.rlim_max);
}
Index: container.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/container.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- container.c 26 Nov 2004 04:00:52 -0000 1.8
+++ container.c 28 Nov 2004 09:05:45 -0000 1.9
@@ -104,10 +104,10 @@
*/
void smartlist_remove(smartlist_t *sl, void *element) {
int i;
- if(element == NULL)
+ if (element == NULL)
return;
- for(i=0; i < sl->num_used; i++)
- if(sl->list[i] == element) {
+ for (i=0; i < sl->num_used; i++)
+ if (sl->list[i] == element) {
sl->list[i] = sl->list[--sl->num_used]; /* swap with the end */
i--; /* so we process the new i'th element */
}
@@ -117,16 +117,16 @@
*/
int smartlist_isin(const smartlist_t *sl, void *element) {
int i;
- for(i=0; i < sl->num_used; i++)
- if(sl->list[i] == element)
+ for (i=0; i < sl->num_used; i++)
+ if (sl->list[i] == element)
return 1;
return 0;
}
int smartlist_string_isin(const smartlist_t *sl, const char *element) {
int i;
- for(i=0; i < sl->num_used; i++)
- if(strcmp((const char*)sl->list[i],element)==0)
+ for (i=0; i < sl->num_used; i++)
+ if (strcmp((const char*)sl->list[i],element)==0)
return 1;
return 0;
}
@@ -135,8 +135,8 @@
*/
int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2) {
int i;
- for(i=0; i < sl2->num_used; i++)
- if(smartlist_isin(sl1, sl2->list[i]))
+ for (i=0; i < sl2->num_used; i++)
+ if (smartlist_isin(sl1, sl2->list[i]))
return 1;
return 0;
}
@@ -146,8 +146,8 @@
*/
void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2) {
int i;
- for(i=0; i < sl1->num_used; i++)
- if(!smartlist_isin(sl2, sl1->list[i])) {
+ for (i=0; i < sl1->num_used; i++)
+ if (!smartlist_isin(sl2, sl1->list[i])) {
sl1->list[i] = sl1->list[--sl1->num_used]; /* swap with the end */
i--; /* so we process the new i'th element */
}
@@ -158,7 +158,7 @@
*/
void smartlist_subtract(smartlist_t *sl1, const smartlist_t *sl2) {
int i;
- for(i=0; i < sl2->num_used; i++)
+ for (i=0; i < sl2->num_used; i++)
smartlist_remove(sl1, sl2->list[i]);
}
@@ -544,7 +544,7 @@
* iter = strmap_iter_next_rmv(iter);
* free(val);
* } else {
- * for(;*cp;cp++) *cp = toupper(*cp);
+ * for (;*cp;cp++) *cp = toupper(*cp);
* iter = strmap_iter_next(iter);
* }
* }
Index: container.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/container.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- container.h 26 Nov 2004 04:00:52 -0000 1.6
+++ container.h 28 Nov 2004 09:05:45 -0000 1.7
@@ -60,7 +60,7 @@
do { \
int var ## _sl_idx, var ## _sl_len=smartlist_len(sl); \
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 = smartlist_get((sl),var ## _sl_idx); \
cmd; \
Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/crypto.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -d -r1.123 -r1.124
--- crypto.c 26 Nov 2004 04:00:52 -0000 1.123
+++ crypto.c 28 Nov 2004 09:05:45 -0000 1.124
@@ -103,7 +103,7 @@
*/
static INLINE int
crypto_get_rsa_padding_overhead(int padding) {
- switch(padding)
+ switch (padding)
{
case RSA_NO_PADDING: return 0;
case RSA_PKCS1_OAEP_PADDING: return 42;
@@ -116,7 +116,7 @@
*/
static INLINE int
crypto_get_rsa_padding(int padding) {
- switch(padding)
+ switch (padding)
{
case PK_NO_PADDING: return RSA_NO_PADDING;
case PK_PKCS1_PADDING: return RSA_PKCS1_PADDING;
@@ -238,7 +238,7 @@
{
tor_assert(env);
- if(--env->refs > 0)
+ if (--env->refs > 0)
return;
if (env->key)
@@ -398,7 +398,7 @@
/* Now you can treat b as if it were a file. Just use the
* 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");
return -1;
}
@@ -435,7 +435,7 @@
RSA_free(env->key);
env->key = PEM_read_bio_RSAPublicKey(b, NULL, NULL, NULL);
BIO_free(b);
- if(!env->key) {
+ if (!env->key) {
crypto_log_errors(LOG_WARN, "reading public key from string");
return -1;
}
@@ -1346,7 +1346,7 @@
goto error;
secret_tmp = tor_malloc(crypto_dh_get_bytes(dh)+1);
result = DH_compute_key(secret_tmp, pubkey_bn, dh->dh);
- if(result < 0) {
+ if (result < 0) {
log_fn(LOG_WARN,"DH_compute_key() failed.");
goto error;
}
@@ -1368,7 +1368,7 @@
if (pubkey_bn)
BN_free(pubkey_bn);
tor_free(secret_tmp);
- if(result < 0)
+ if (result < 0)
return result;
else
return secret_len;
@@ -1486,7 +1486,7 @@
* range.
*/
cutoff = UINT_MAX - (UINT_MAX%max);
- while(1) {
+ while (1) {
crypto_pseudo_rand((unsigned char*) &val, sizeof(val));
if (val < cutoff)
return val % max;
@@ -1498,7 +1498,7 @@
void *smartlist_choose(const smartlist_t *sl) {
size_t len;
len = smartlist_len(sl);
- if(len)
+ if (len)
return smartlist_get(sl,crypto_pseudo_rand_int(len));
return NULL; /* no elements to choose from */
}
Index: log.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/log.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- log.c 26 Nov 2004 04:00:52 -0000 1.76
+++ log.c 28 Nov 2004 09:05:45 -0000 1.77
@@ -34,7 +34,7 @@
/** Helper: map a log severity to descriptive string. */
static INLINE const char *sev_to_string(int severity) {
- switch(severity) {
+ switch (severity) {
case LOG_DEBUG: return "debug";
case LOG_INFO: return "info";
case LOG_NOTICE: return "notice";
@@ -136,7 +136,7 @@
}
r = tor_vsnprintf(buf+n,buf_len-n,format,ap);
- if(r < 0) {
+ if (r < 0) {
n = buf_len-2;
strlcpy(buf+buf_len-TRUNCATED_STR_LEN-1, TRUNCATED_STR,
buf_len-(buf_len-TRUNCATED_STR_LEN-1));
@@ -162,7 +162,7 @@
assert(format);
lf = logfiles;
- while(lf) {
+ while (lf) {
if (severity > lf->loglevel || severity < lf->max_loglevel) {
lf = lf->next;
continue;
@@ -188,7 +188,7 @@
lf = lf->next;
continue;
}
- if(fputs(buf, lf->file) == EOF ||
+ if (fputs(buf, lf->file) == EOF ||
fflush(lf->file) == EOF) { /* error */
/* don't log the error! Blow away this log entry and continue. */
logfile_t *victim = lf;
@@ -234,7 +234,7 @@
void close_logs()
{
logfile_t *victim;
- while(logfiles) {
+ while (logfiles) {
victim = logfiles;
logfiles = logfiles->next;
close_log(victim);
@@ -247,7 +247,7 @@
void reset_logs()
{
logfile_t *lf = logfiles;
- while(lf) {
+ while (lf) {
if (reset_log(lf)) {
/* error. don't log it. delete the log entry and continue. */
logfile_t *victim = lf;
@@ -266,10 +266,10 @@
*/
static void delete_log(logfile_t *victim) {
logfile_t *tmpl;
- if(victim == logfiles)
+ if (victim == logfiles)
logfiles = victim->next;
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->next == victim);
tmpl->next = victim->next;
Index: log.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/log.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- log.h 26 Nov 2004 04:00:52 -0000 1.37
+++ log.h 28 Nov 2004 09:05:45 -0000 1.38
@@ -90,7 +90,7 @@
extern const char *_log_fn_function_name;
void _log_fn(int severity, const char *format, ...);
/* 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. */
#define log_fn (_log_fn_function_name=__FUNCTION__),_log_fn
#endif
Index: test.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/test.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- test.h 26 Nov 2004 04:00:52 -0000 1.15
+++ test.h 28 Nov 2004 09:05:45 -0000 1.16
@@ -36,7 +36,7 @@
#define test_assert(expr) \
STMT_BEGIN \
- if(expr) { printf("."); fflush(stdout); } else { \
+ if (expr) { printf("."); fflush(stdout); } else { \
have_failed = 1; \
printf("\nFile %s: line %d (%s): assertion failed: (%s)\n", \
__FILE__, \
@@ -49,7 +49,7 @@
#define test_eq(expr1, expr2) \
STMT_BEGIN \
long v1=(long)(expr1), v2=(long)(expr2); \
- if(v1==v2) { printf("."); fflush(stdout); } else { \
+ if (v1==v2) { printf("."); fflush(stdout); } else { \
have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\
" (%ld != %ld)\n", \
@@ -64,7 +64,7 @@
#define test_neq(expr1, expr2) \
STMT_BEGIN \
long v1=(long)(expr1), v2=(long)(expr2); \
- if(v1!=v2) { printf("."); fflush(stdout); } else { \
+ if (v1!=v2) { printf("."); fflush(stdout); } else { \
have_failed = 1; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\
" (%ld == %ld)\n", \
@@ -79,7 +79,7 @@
#define test_streq(expr1, expr2) \
STMT_BEGIN \
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; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\
" (\"%s\" != \"%s\")\n", \
@@ -94,7 +94,7 @@
#define test_strneq(expr1, expr2) \
STMT_BEGIN \
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; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\
" (\"%s\" == \"%s\")\n", \
@@ -109,7 +109,7 @@
#define test_memeq(expr1, expr2, len) \
STMT_BEGIN \
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; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n", \
__FILE__, \
@@ -122,7 +122,7 @@
#define test_memneq(expr1, expr2, len) \
STMT_BEGIN \
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; \
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n", \
__FILE__, \
Index: torgzip.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/torgzip.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- torgzip.c 26 Nov 2004 04:00:52 -0000 1.7
+++ torgzip.c 28 Nov 2004 09:05:45 -0000 1.8
@@ -176,7 +176,7 @@
stream->avail_out = out_size;
while (1) {
- switch(inflate(stream, Z_FINISH))
+ switch (inflate(stream, Z_FINISH))
{
case Z_STREAM_END:
goto done;
Index: tortls.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/tortls.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- tortls.c 26 Nov 2004 04:00:52 -0000 1.78
+++ tortls.c 28 Nov 2004 09:05:45 -0000 1.79
@@ -466,7 +466,7 @@
tor_assert(tls->state == TOR_TLS_ST_OPEN);
if (n == 0)
return 0;
- if(tls->wantwrite_n) {
+ if (tls->wantwrite_n) {
/* if WANTWRITE last time, we must use the _same_ n as before */
tor_assert(n >= tls->wantwrite_n);
log_fn(LOG_DEBUG,"resuming pending-write, (%d to flush, reusing %d)",
Index: util.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.185
retrieving revision 1.186
diff -u -d -r1.185 -r1.186
--- util.c 26 Nov 2004 04:00:52 -0000 1.185
+++ util.c 28 Nov 2004 09:05:46 -0000 1.186
@@ -108,7 +108,7 @@
}
result = malloc(size);
- if(!result) {
+ if (!result) {
log_fn(LOG_ERR, "Out of memory. Dying.");
exit(1);
}
@@ -150,7 +150,7 @@
tor_assert(s);
dup = strdup(s);
- if(!dup) {
+ if (!dup) {
log_fn(LOG_ERR,"Out of memory. Dying.");
exit(1);
}
@@ -221,7 +221,7 @@
len_ins = strlen(insert);
len_out = len_in + (len_in/n)*len_ins;
is_even = (len_in%n) == 0;
- switch(rule)
+ switch (rule)
{
case ALWAYS_TERMINATE:
if (!is_even) len_out += len_ins;
@@ -236,7 +236,7 @@
return -1;
destp = dest;
remaining = len_in;
- while(remaining) {
+ while (remaining) {
strncpy(destp, s, n);
remaining -= n;
if (remaining < 0) {
@@ -306,13 +306,13 @@
const char *eat_whitespace(const char *s) {
tor_assert(s);
- while(isspace((int)*s) || *s == '#') {
- while(isspace((int)*s))
+ while (isspace((int)*s) || *s == '#') {
+ while (isspace((int)*s))
s++;
- if(*s == '#') { /* read to a \n or \0 */
- while(*s && *s != '\n')
+ if (*s == '#') { /* read to a \n or \0 */
+ while (*s && *s != '\n')
s++;
- if(!*s)
+ if (!*s)
return s;
}
}
@@ -322,7 +322,7 @@
/** 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. */
const char *eat_whitespace_no_nl(const char *s) {
- while(*s == ' ' || *s == '\t')
+ while (*s == ' ' || *s == '\t')
++s;
return s;
}
@@ -333,7 +333,7 @@
const char *find_whitespace(const char *s) {
tor_assert(s);
- while(*s && !isspace((int)*s) && *s != '#')
+ while (*s && !isspace((int)*s) && *s != '#')
s++;
return s;
@@ -402,8 +402,8 @@
tor_assert(base <= 10);
r = (uint64_t)_atoi64(s);
endptr = (char*)s;
- while(isspace(*endptr)) endptr++;
- while(isdigit(*endptr)) endptr++;
+ while (isspace(*endptr)) endptr++;
+ while (isdigit(*endptr)) endptr++;
#else
r = (uint64_t)_strtoui64(s, &endptr, base);
#endif
@@ -461,7 +461,7 @@
while (src<end) {
v1 = hex_decode_digit(*src);
v2 = hex_decode_digit(*(src+1));
- if(v1<0||v2<0)
+ if (v1<0||v2<0)
return -1;
*(uint8_t*)dest = (v1<<4)|v2;
++dest;
@@ -659,12 +659,12 @@
size_t written = 0;
int result;
- while(written != count) {
+ while (written != count) {
if (isSocket)
result = send(fd, buf+written, count-written, 0);
else
result = write(fd, buf+written, count-written);
- if(result<0)
+ if (result<0)
return -1;
written += result;
}
@@ -681,12 +681,12 @@
size_t numread = 0;
int result;
- while(numread != count) {
+ while (numread != count) {
if (isSocket)
result = recv(fd, buf+numread, count-numread, 0);
else
result = read(fd, buf+numread, count-numread);
- if(result<0)
+ if (result<0)
return -1;
else if (result == 0)
break;
@@ -815,7 +815,7 @@
return -1;
}
result = write_all(fd, str, len, 0);
- if(result < 0 || (size_t)result != len) {
+ if (result < 0 || (size_t)result != len) {
log(LOG_WARN, "Error writing to %s: %s", tempname, strerror(errno));
close(fd);
return -1;
@@ -842,7 +842,7 @@
tor_assert(filename);
- if(stat(filename, &statbuf) < 0) {
+ if (stat(filename, &statbuf) < 0) {
log_fn(LOG_INFO,"Could not stat %s.",filename);
return NULL;
}
@@ -1260,7 +1260,7 @@
return;
start_daemon_called = 1;
- if(!desired_cwd)
+ if (!desired_cwd)
desired_cwd = "/";
/* Don't hold the wrong FS mounted */
if (chdir(desired_cwd) < 0) {
Index: util.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.h,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -d -r1.120 -r1.121
--- util.h 26 Nov 2004 04:00:52 -0000 1.120
+++ util.h 28 Nov 2004 09:05:46 -0000 1.121
@@ -24,7 +24,7 @@
* calling assert() normally.
*/
#ifdef NDEBUG
-#define tor_assert(expr) do {} while(0)
+#define tor_assert(expr) do {} while (0)
#else
#define tor_assert(expr) do { \
if (!(expr)) { \
@@ -41,7 +41,7 @@
void *tor_realloc(void *ptr, size_t size);
char *tor_strdup(const char *s);
char *tor_strndup(const char *s, size_t n);
-#define tor_free(p) do {if(p) {free(p); (p)=NULL;}} while(0)
+#define tor_free(p) do { if (p) {free(p); (p)=NULL;} } while (0)
/* String manipulation */
#define HEX_CHARACTERS "0123456789ABCDEFabcdef"