Commit 9568c0ce authored by Nick Mathewson's avatar Nick Mathewson 🤹
Browse files

Return U64_PRINTF_ARG and U64_FORMAT

The standard is printf("%"PRIu64, x);
parent 52884f56
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -188,11 +188,6 @@
#define MINGW_ANY
#endif

#define U64_PRINTF_ARG(a) ((uint64_t)a)
#define I64_PRINTF_ARG(a) ((int64_t)a)
#define U64_FORMAT "%"PRIu64
#define I64_FORMAT "%"PRId64

/** Macro: yield a pointer to the field at position <b>off</b> within the
 * structure <b>st</b>.  Example:
 * <pre>
+10 −10
Original line number Diff line number Diff line
@@ -51,15 +51,15 @@ tv_udiff(const struct timeval *start, const struct timeval *end)
  /* Sanity check tv_usec */
  if (start->tv_usec > TOR_USEC_PER_SEC || start->tv_usec < 0) {
    log_warn(LD_GENERAL, "comparing times on microsecond detail with bad "
             "start tv_usec: " I64_FORMAT " microseconds",
             I64_PRINTF_ARG(start->tv_usec));
             "start tv_usec: %"PRId64 " microseconds",
             (start->tv_usec));
    return LONG_MAX;
  }

  if (end->tv_usec > TOR_USEC_PER_SEC || end->tv_usec < 0) {
    log_warn(LD_GENERAL, "comparing times on microsecond detail with bad "
             "end tv_usec: " I64_FORMAT " microseconds",
             I64_PRINTF_ARG(end->tv_usec));
             "end tv_usec: %"PRId64 " microseconds",
             (end->tv_usec));
    return LONG_MAX;
  }

@@ -72,7 +72,7 @@ tv_udiff(const struct timeval *start, const struct timeval *end)
  if (secdiff > (int64_t)(LONG_MAX/1000000 - 1) ||
      secdiff < (int64_t)(LONG_MIN/1000000 + 1)) {
    log_warn(LD_GENERAL, "comparing times on microsecond detail too far "
             "apart: " I64_FORMAT " seconds", I64_PRINTF_ARG(secdiff));
             "apart: %"PRId64 " seconds", (secdiff));
    return LONG_MAX;
  }

@@ -100,15 +100,15 @@ tv_mdiff(const struct timeval *start, const struct timeval *end)
  /* Sanity check tv_usec */
  if (start->tv_usec > TOR_USEC_PER_SEC || start->tv_usec < 0) {
    log_warn(LD_GENERAL, "comparing times on millisecond detail with bad "
             "start tv_usec: " I64_FORMAT " microseconds",
             I64_PRINTF_ARG(start->tv_usec));
             "start tv_usec: %"PRId64 " microseconds",
             (start->tv_usec));
    return LONG_MAX;
  }

  if (end->tv_usec > TOR_USEC_PER_SEC || end->tv_usec < 0) {
    log_warn(LD_GENERAL, "comparing times on millisecond detail with bad "
             "end tv_usec: " I64_FORMAT " microseconds",
             I64_PRINTF_ARG(end->tv_usec));
             "end tv_usec: %"PRId64 " microseconds",
             (end->tv_usec));
    return LONG_MAX;
  }

@@ -124,7 +124,7 @@ tv_mdiff(const struct timeval *start, const struct timeval *end)
  if (secdiff > (int64_t)(LONG_MAX/1000 - 2) ||
      secdiff < (int64_t)(LONG_MIN/1000 + 1)) {
    log_warn(LD_GENERAL, "comparing times on millisecond detail too far "
             "apart: " I64_FORMAT " seconds", I64_PRINTF_ARG(secdiff));
             "apart: %"PRId64 " seconds", (secdiff));
    return LONG_MAX;
  }

+2 −2
Original line number Diff line number Diff line
@@ -100,9 +100,9 @@ correct_tm(int islocal, const time_t *timep, struct tm *resultbuf,
  /* LCOV_EXCL_STOP */
 done:
  if (err_out) {
    tor_asprintf(err_out, "%s("I64_FORMAT") failed with error %s: %s",
    tor_asprintf(err_out, "%s(%"PRId64") failed with error %s: %s",
                 islocal?"localtime":"gmtime",
                 timep?I64_PRINTF_ARG(*timep):0,
                 timep?(*timep):0,
                 strerror(errno),
                 outcome);
  }
+145 −145

File changed.

Preview size limit exceeded, changes collapsed.

+13 −13
Original line number Diff line number Diff line
@@ -282,10 +282,10 @@ channelpadding_update_padding_for_channel(channel_t *chan,
                                      pad_vars->ito_high_ms);

  log_fn(LOG_INFO,LD_OR,
         "Negotiated padding=%d, lo=%d, hi=%d on "U64_FORMAT,
         "Negotiated padding=%d, lo=%d, hi=%d on %"PRIu64,
         chan->padding_enabled, chan->padding_timeout_low_ms,
         chan->padding_timeout_high_ms,
         U64_PRINTF_ARG(chan->global_identifier));
         (chan->global_identifier));

  return 1;
}
@@ -393,13 +393,13 @@ channelpadding_send_padding_cell_for_callback(channel_t *chan)
    monotime_coarse_get(&now);

    log_fn(LOG_INFO,LD_OR,
        "Sending netflow keepalive on "U64_FORMAT" to %s (%s) after "
        I64_FORMAT" ms. Delta "I64_FORMAT"ms",
        U64_PRINTF_ARG(chan->global_identifier),
        "Sending netflow keepalive on %"PRIu64" to %s (%s) after "
        "%"PRId64" ms. Delta %"PRId64"ms",
        (chan->global_identifier),
        safe_str_client(chan->get_remote_descr(chan, 0)),
        safe_str_client(hex_str(chan->identity_digest, DIGEST_LEN)),
        I64_PRINTF_ARG(monotime_coarse_diff_msec(&chan->timestamp_xfer,&now)),
        I64_PRINTF_ARG(
        (monotime_coarse_diff_msec(&chan->timestamp_xfer,&now)),
        (
                   monotime_coarse_diff_msec(&chan->next_padding_time,&now)));
  }

@@ -539,9 +539,9 @@ channelpadding_compute_time_until_pad_for_netflow(channel_t *chan)
  if (ms_till_pad > DFLT_NETFLOW_INACTIVE_KEEPALIVE_MAX) {
    tor_fragile_assert();
    log_warn(LD_BUG,
        "Channel padding timeout scheduled "I64_FORMAT"ms in the future. "
        "Channel padding timeout scheduled %"PRId64"ms in the future. "
        "Did the monotonic clock just jump?",
        I64_PRINTF_ARG(ms_till_pad));
        (ms_till_pad));
    return 0; /* Clock jumped: Send padding now */
  }

@@ -565,8 +565,8 @@ channelpadding_compute_time_until_pad_for_netflow(channel_t *chan)
      int severity = (ms_till_pad < -NETFLOW_MISSED_WINDOW)
                      ? LOG_NOTICE : LOG_INFO;
      log_fn(severity, LD_OR,
              "Channel padding timeout scheduled "I64_FORMAT"ms in the past. ",
             I64_PRINTF_ARG(-ms_till_pad));
              "Channel padding timeout scheduled %"PRId64"ms in the past. ",
             (-ms_till_pad));
      return 0; /* Clock jumped: Send padding now */
    }

@@ -697,8 +697,8 @@ channelpadding_reduce_padding_on_channel(channel_t *chan)
  chan->padding_timeout_high_ms = consensus_nf_ito_high_reduced;

  log_fn(LOG_INFO,LD_OR,
         "Reduced padding on channel "U64_FORMAT": lo=%d, hi=%d",
         U64_PRINTF_ARG(chan->global_identifier),
         "Reduced padding on channel %"PRIu64": lo=%d, hi=%d",
         (chan->global_identifier),
         chan->padding_timeout_low_ms, chan->padding_timeout_high_ms);
}

Loading