diff --git a/core/log_io.c b/core/log_io.c index 9c8d669788256b067345fac07f9f5045f1390d7a..3d36719285ef250acd8516affed2a87f182e854d 100644 --- a/core/log_io.c +++ b/core/log_io.c @@ -116,7 +116,7 @@ next_lsn(struct recovery_state *r, i64 new_lsn) else r->lsn = new_lsn; - say_debug("next_lsn(%p, %"PRIi64") => %"PRIi64, r, new_lsn, r->lsn); + say_debug("next_lsn(%p, %" PRIi64 ") => %" PRIi64, r, new_lsn, r->lsn); return r->lsn; } @@ -252,7 +252,8 @@ read_rows(struct log_io_iter *i) say_debug("eof while looking for magic"); goto eof; } - magic = (magic >> 8) | (((u64)c & 0xff) << ((l->class->marker_size - 1) * 8)); + magic >>= 8; + magic |= (((u64)c & 0xff) << ((l->class->marker_size - 1) * 8)); } marker_offset = ftello(l->f) - l->class->marker_size; if (good_offset != marker_offset) @@ -503,7 +504,6 @@ row_reader_v04(FILE *f, struct palloc_pool *pool) return convert_to_v11(data, row_v04(m)->lsn); } - static struct tbuf * row_reader_v11(FILE *f, struct palloc_pool *pool) { @@ -542,7 +542,6 @@ row_reader_v11(FILE *f, struct palloc_pool *pool) return m; } - int close_log(struct log_io **lptr) { @@ -1004,7 +1003,8 @@ recover_remaining_wals(struct recovery_state *r) result = -1; break; } else { - name = format_filename(NULL, r->wal_prefered_class, current_lsn, suffix + 1); + name = format_filename(NULL, r->wal_prefered_class, + current_lsn, suffix + 1); if (access(name, F_OK) == 0) { say_error("found conflicter `%s' after successful reading", name); result = -1; @@ -1048,8 +1048,7 @@ recover(struct recovery_state *r, i64 lsn) result = recover_snap(r); if (result < 0) { if (greatest_lsn(r->snap_prefered_class) <= 0) { - say_crit - ("don't you forget to initialize storage with --init_storage switch?"); + say_crit("don't you forget to initialize storage with --init_storage switch?"); _exit(1); } panic("snapshot recovery failed"); @@ -1157,8 +1156,7 @@ recover_finalize(struct recovery_state *r) panic("unable to scucessfully finalize recovery"); if (r->current_wal != NULL && result != LOG_EOF) { - say_warn("wal `%s' wasn't correctly closed", - r->current_wal->filename); + say_warn("wal `%s' wasn't correctly closed", r->current_wal->filename); close_log(&r->current_wal); } } @@ -1277,7 +1275,6 @@ wal_write(struct recovery_state *r, i64 lsn, struct tbuf *data) return reply == 0; } - struct recovery_state * recover_init(const char *snap_dirname, const char *wal_dirname, row_reader snap_row_reader, row_handler snap_row_handler, row_handler wal_row_handler, @@ -1325,13 +1322,14 @@ write_rows(struct log_io_iter *i) if (fwrite(&l->class->marker, l->class->marker_size, 1, l->f) != 1) panic("fwrite"); - row_v11(row)->lsn = 0; /* unused */ + row_v11(row)->lsn = 0; /* unused */ row_v11(row)->tm = ev_now(); row_v11(row)->len = data->len; row_v11(row)->data_crc32c = crc32c(0, data->data, data->len); row_v11(row)->header_crc32c = crc32c(0, row->data + field_sizeof(struct row_v11, header_crc32c), - sizeof(struct row_v11) - field_sizeof(struct row_v11, header_crc32c)); + sizeof(struct row_v11) - field_sizeof(struct row_v11, + header_crc32c)); if (fwrite(row->data, row->len, 1, l->f) != 1) panic("fwrite"); diff --git a/core/log_io_remote.c b/core/log_io_remote.c index 4a47d6787d6914ce25ff7187559c66e5475b658a..cc0d6b7646c2a53cd2de08d46a7a185e4029820e 100644 --- a/core/log_io_remote.c +++ b/core/log_io_remote.c @@ -38,13 +38,11 @@ #include <log_io.h> #include "log_io_internal.h" - struct remote_state { struct recovery_state *r; - int (*handler)(struct recovery_state *r, struct tbuf *row); + int (*handler) (struct recovery_state *r, struct tbuf *row); }; - static struct tbuf * row_reader_v11(struct palloc_pool *pool) { @@ -113,7 +111,7 @@ remote_read_row(i64 initial_lsn) return row; - err: + err: if (err != NULL && !warning_said) { say_info("%s", err); say_info("will retry every %i second", reconnect_delay); @@ -140,7 +138,6 @@ pull_from_remote(void *state) } } - int default_remote_row_handler(struct recovery_state *r, struct tbuf *row) { @@ -164,7 +161,8 @@ default_remote_row_handler(struct recovery_state *r, struct tbuf *row) } struct fiber * -recover_follow_remote(struct recovery_state *r, char *ip_addr, int port, int (*handler)(struct recovery_state *r, struct tbuf *row)) +recover_follow_remote(struct recovery_state *r, char *ip_addr, int port, + int (*handler) (struct recovery_state *r, struct tbuf *row)) { char *name; struct fiber *f; diff --git a/core/pickle.c b/core/pickle.c index fed019b87412bf4631819dfdd7f8d174f35015ee..e0b770ad589f598c9fc32b24b6c2d2589e858a33 100644 --- a/core/pickle.c +++ b/core/pickle.c @@ -160,7 +160,7 @@ read_varint32(struct tbuf *buf) buf->size -= 4; buf->len -= 4; return (b[0] & 0x7f) << 21 | (b[1] & 0x7f) << 14 | - (b[2] & 0x7f) << 7 | (b[3] & 0x7f); + (b[2] & 0x7f) << 7 | (b[3] & 0x7f); } if (len < 5) @@ -170,7 +170,7 @@ read_varint32(struct tbuf *buf) buf->size -= 5; buf->len -= 5; return (b[0] & 0x7f) << 28 | (b[1] & 0x7f) << 21 | - (b[2] & 0x7f) << 14 | (b[3] & 0x7f) << 7 | (b[4] & 0x7f); + (b[2] & 0x7f) << 14 | (b[3] & 0x7f) << 7 | (b[4] & 0x7f); } raise(ERR_CODE_UNKNOWN_ERROR, "imposible happend"); diff --git a/core/stat.c b/core/stat.c index aebd794003782a1477568d4be7687d98a1108efe..cae1ff1ef70d925dfe421e3d5dfb1379d9d2e5b3 100644 --- a/core/stat.c +++ b/core/stat.c @@ -43,7 +43,6 @@ static int stats_size = 0; static int stats_max = 0; static int base = 0; - int stat_register(char **name, size_t count) { @@ -78,7 +77,6 @@ stat_collect(int base, int name, i64 value) stats[base + name].value[SECS] += value; } - void stat_print(struct tbuf *buf) { diff --git a/core/tarantool.c b/core/tarantool.c index fe520c8876f83de86b4a2f26ad967e0f80f30bfe..ef5a5d2e07d975f85d589f05e4b2b0dad4692557 100644 --- a/core/tarantool.c +++ b/core/tarantool.c @@ -111,7 +111,7 @@ sig_int(int signal) { say_info("SIGINT or SIGTERM recieved, terminating"); - if (recovery_state != NULL) { + if (recovery_state !=NULL) { struct child *writer = wal_writer(recovery_state); if (writer && writer->out && writer->out->fd > 0) { close(writer->out->fd); diff --git a/include/log_io.h b/include/log_io.h index e783b94d19d65b0cf7b3da45dfc972cd90d1b9a2..8643acf57b1e11cc9714796694b039aa5a75ffbd 100644 --- a/include/log_io.h +++ b/include/log_io.h @@ -42,8 +42,8 @@ extern const u32 default_version; struct log_io; struct recovery_state; -typedef int (row_handler)(struct recovery_state *, struct tbuf *); -typedef struct tbuf *(row_reader)(FILE *f, struct palloc_pool * pool); +typedef int (row_handler) (struct recovery_state *, struct tbuf *); +typedef struct tbuf *(row_reader) (FILE *f, struct palloc_pool *pool); struct row_v04 { i64 lsn; /* this used to be tid */ u16 type; @@ -92,11 +92,9 @@ struct child *wal_writer(struct recovery_state *r); int read_log(const char *filename, row_reader reader, row_handler xlog_handler, row_handler snap_handler, void *state); - int default_remote_row_handler(struct recovery_state *r, struct tbuf *row); struct fiber *recover_follow_remote(struct recovery_state *r, char *ip_addr, int port, - int (*handler)(struct recovery_state *r, struct tbuf *row)); - + int (*handler) (struct recovery_state *r, struct tbuf *row)); struct log_io_iter; void snapshot_write_row(struct log_io_iter *i, struct tbuf *row); diff --git a/include/pickle.h b/include/pickle.h index ee09f744588bb719e114291c810440734ead2276..250ba240adeb1157b4babe14b41b7aa28adb5d4a 100644 --- a/include/pickle.h +++ b/include/pickle.h @@ -63,12 +63,12 @@ inline static u32 load_varint32(void **data) if (!(b[3] & 0x80)) { *data += 4; return (b[0] & 0x7f) << 21 | (b[1] & 0x7f) << 14 | - (b[2] & 0x7f) << 7 | (b[3] & 0x7f); + (b[2] & 0x7f) << 7 | (b[3] & 0x7f); } if (!(b[4] & 0x80)) { *data += 5; return (b[0] & 0x7f) << 28 | (b[1] & 0x7f) << 21 | - (b[2] & 0x7f) << 14 | (b[3] & 0x7f) << 7 | (b[4] & 0x7f); + (b[2] & 0x7f) << 14 | (b[3] & 0x7f) << 7 | (b[4] & 0x7f); } assert(false);