diff options
author | Nicolas Noble <nnoble@google.com> | 2015-02-23 15:28:04 -0800 |
---|---|---|
committer | Nicolas Noble <nnoble@google.com> | 2015-02-23 15:38:52 -0800 |
commit | 65b0759653bf36e6ed71e61f57796b85ab6f5ac9 (patch) | |
tree | fdf9241644f6686f6836219fa59c731574471b54 /src/core | |
parent | 74ae8f61d9cbc51d532b6ad98185094c1912a624 (diff) |
Addressing a first batch of feedback.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/support/log_win32.c | 2 | ||||
-rw-r--r-- | src/core/support/string_posix.c | 2 | ||||
-rw-r--r-- | src/core/support/sync.c | 4 | ||||
-rw-r--r-- | src/core/support/time.c | 14 |
4 files changed, 11 insertions, 11 deletions
diff --git a/src/core/support/log_win32.c b/src/core/support/log_win32.c index cff130ae18..720dc141f5 100644 --- a/src/core/support/log_win32.c +++ b/src/core/support/log_win32.c @@ -90,7 +90,7 @@ void gpr_default_log(gpr_log_func_args *args) { strcpy(time_buffer, "error:strftime"); } - fprintf(stderr, "%s%s.%09u %5u %s:%d: %s\n", + fprintf(stderr, "%s%s.%09u %5u %s:%d] %s\n", gpr_log_severity_string(args->severity), time_buffer, (int)(now.tv_nsec), GetCurrentThreadId(), args->file, args->line, args->message); diff --git a/src/core/support/string_posix.c b/src/core/support/string_posix.c index 8a678b3103..25c333db4e 100644 --- a/src/core/support/string_posix.c +++ b/src/core/support/string_posix.c @@ -51,7 +51,7 @@ int gpr_asprintf(char **strp, const char *format, ...) { va_start(args, format); ret = vsnprintf(buf, sizeof(buf), format, args); va_end(args); - if (!(0 <= ret)) { + if (ret < 0) { *strp = NULL; return -1; } diff --git a/src/core/support/sync.c b/src/core/support/sync.c index 1a5cf57c4f..ccfe1e25f4 100644 --- a/src/core/support/sync.c +++ b/src/core/support/sync.c @@ -41,7 +41,7 @@ Should be a prime. */ enum { event_sync_partitions = 31 }; -/* Event are partitioned by address to avoid lock contention. */ +/* Events are partitioned by address to avoid lock contention. */ static struct sync_array_s { gpr_mu mu; gpr_cv cv; @@ -71,10 +71,10 @@ void gpr_event_set(gpr_event *ev, void *value) { struct sync_array_s *s = hash(ev); gpr_mu_lock(&s->mu); GPR_ASSERT(gpr_atm_acq_load(&ev->state) == 0); - GPR_ASSERT(value != NULL); gpr_atm_rel_store(&ev->state, (gpr_atm)value); gpr_cv_broadcast(&s->cv); gpr_mu_unlock(&s->mu); + GPR_ASSERT(value != NULL); } void *gpr_event_get(gpr_event *ev) { diff --git a/src/core/support/time.c b/src/core/support/time.c index 67f7665650..7dbf95059f 100644 --- a/src/core/support/time.c +++ b/src/core/support/time.c @@ -85,12 +85,12 @@ gpr_timespec gpr_time_from_nanos(long ns) { } else if (ns == LONG_MIN) { result = gpr_inf_past; } else if (ns >= 0) { - result.tv_sec = ns / 1000000000; - result.tv_nsec = ns - result.tv_sec * 1000000000; + result.tv_sec = ns / GPR_NS_PER_SEC; + result.tv_nsec = ns - result.tv_sec * GPR_NS_PER_SEC; } else { /* Calculation carefully formulated to avoid any possible under/overflow. */ - result.tv_sec = (-(999999999 - (ns + 1000000000)) / 1000000000) - 1; - result.tv_nsec = ns - result.tv_sec * 1000000000; + result.tv_sec = (-(999999999 - (ns + GPR_NS_PER_SEC)) / GPR_NS_PER_SEC) - 1; + result.tv_nsec = ns - result.tv_sec * GPR_NS_PER_SEC; } return result; } @@ -172,8 +172,8 @@ gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b) { gpr_timespec sum; int inc = 0; sum.tv_nsec = a.tv_nsec + b.tv_nsec; - if (sum.tv_nsec >= 1000000000) { - sum.tv_nsec -= 1000000000; + if (sum.tv_nsec >= GPR_NS_PER_SEC) { + sum.tv_nsec -= GPR_NS_PER_SEC; inc++; } if (a.tv_sec == TYPE_MAX(time_t) || a.tv_sec == TYPE_MIN(time_t)) { @@ -200,7 +200,7 @@ gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b) { int dec = 0; diff.tv_nsec = a.tv_nsec - b.tv_nsec; if (diff.tv_nsec < 0) { - diff.tv_nsec += 1000000000; + diff.tv_nsec += GPR_NS_PER_SEC; dec++; } if (a.tv_sec == TYPE_MAX(time_t) || a.tv_sec == TYPE_MIN(time_t)) { |