diff --git a/cr-show.c b/cr-show.c index c306c4dd9..63d432a8d 100644 --- a/cr-show.c +++ b/cr-show.c @@ -80,16 +80,15 @@ void show_ghost_file(int fd, struct cr_options *o) pb_show_vertical(fd, PB_GHOST_FILE); } -static void pipe_data_handler(int fd, void *obj, int show_pages_content) +static void pipe_data_handler(int fd, void *obj) { PipeDataEntry *e = obj; - print_image_data(fd, e->bytes, show_pages_content); + print_image_data(fd, e->bytes, opts.show_pages_content); } void show_pipes_data(int fd, struct cr_options *o) { - pb_show_plain_payload(fd, PB_PIPES_DATA, - pipe_data_handler, o->show_pages_content); + pb_show_plain_payload(fd, PB_PIPES_DATA, pipe_data_handler); } void show_pipes(int fd_pipes, struct cr_options *o) @@ -277,14 +276,11 @@ static int pstree_item_from_pb(PstreeEntry *e, struct pstree_item *item) return 0; } -static void pstree_handler(int fd, void *obj, int collect) +static void pstree_handler(int fd, void *obj) { PstreeEntry *e = obj; struct pstree_item *item = NULL; - if (!collect) - return; - item = xzalloc(sizeof(struct pstree_item)); if (!item) return; @@ -299,8 +295,9 @@ static void pstree_handler(int fd, void *obj, int collect) void show_collect_pstree(int fd, int collect) { - pb_show_plain_payload_pretty(fd, PB_PSTREE, pstree_handler, - collect, "1:%d 2:%d 3:%d 4:%d 5:%d"); + pb_show_plain_payload_pretty(fd, PB_PSTREE, + collect ? pstree_handler : NULL, + "1:%d 2:%d 3:%d 4:%d 5:%d"); } void show_pstree(int fd, struct cr_options *o) diff --git a/include/protobuf.h b/include/protobuf.h index a974b80fd..9bd666211 100644 --- a/include/protobuf.h +++ b/include/protobuf.h @@ -90,24 +90,24 @@ extern int pb_write_one(int fd, void *obj, int type); #include extern void do_pb_show_plain(int fd, int type, int single_entry, - void (*payload_hadler)(int fd, void *obj, int flags), - int flags, const char *pretty_fmt); + void (*payload_hadler)(int fd, void *obj), + const char *pretty_fmt); /* Don't have objects at hands to also do typechecking here */ -#define pb_show_plain_payload_pretty(__fd, __type, payload_hadler, flags, pretty) \ - do_pb_show_plain(__fd, __type, 0, payload_hadler, flags, pretty) +#define pb_show_plain_payload_pretty(__fd, __type, payload_hadler, pretty) \ + do_pb_show_plain(__fd, __type, 0, payload_hadler, pretty) -#define pb_show_plain_payload(__fd, __proto_message_name, payload_hadler, flags) \ - pb_show_plain_payload_pretty(__fd, __proto_message_name, payload_hadler, flags, NULL) +#define pb_show_plain_payload(__fd, __proto_message_name, payload_hadler) \ + pb_show_plain_payload_pretty(__fd, __proto_message_name, payload_hadler, NULL) #define pb_show_plain_pretty(__fd, __proto_message_name, __pretty) \ - pb_show_plain_payload_pretty(__fd, __proto_message_name, NULL, 0, __pretty) + pb_show_plain_payload_pretty(__fd, __proto_message_name, NULL, __pretty) #define pb_show_plain(__fd, __type) \ - pb_show_plain_payload(__fd, __type, NULL, 0) + pb_show_plain_payload(__fd, __type, NULL) #define pb_show_vertical(__fd, __type) \ - do_pb_show_plain(__fd, __type, 1, NULL, 0, NULL) + do_pb_show_plain(__fd, __type, 1, NULL, NULL) int collect_image(int fd_t, int obj_t, unsigned size, int (*collect)(void *obj, ProtobufCMessage *msg)); diff --git a/ipc_ns.c b/ipc_ns.c index c7993cacd..ec5ff7a3a 100644 --- a/ipc_ns.c +++ b/ipc_ns.c @@ -449,7 +449,7 @@ int dump_ipc_ns(int ns_pid, const struct cr_fdset *fdset) return 0; } -static void ipc_sem_handler(int fd, void *obj, int show_pages_content) +static void ipc_sem_handler(int fd, void *obj) { IpcSemEntry *e = obj; u16 *values; @@ -469,42 +469,40 @@ static void ipc_sem_handler(int fd, void *obj, int show_pages_content) void show_ipc_sem(int fd, struct cr_options *o) { - pb_show_plain_payload(fd, PB_IPCNS_SEM, ipc_sem_handler, 0); + pb_show_plain_payload(fd, PB_IPCNS_SEM, ipc_sem_handler); } -static void ipc_msg_data_handler(int fd, void *obj, int show_pages_content) +static void ipc_msg_data_handler(int fd, void *obj) { IpcMsg *e = obj; - print_image_data(fd, round_up(e->msize, sizeof(u64)), show_pages_content); + print_image_data(fd, round_up(e->msize, sizeof(u64)), opts.show_pages_content); } -static void ipc_msg_handler(int fd, void *obj, int show_pages_content) +static void ipc_msg_handler(int fd, void *obj) { IpcMsgEntry *e = obj; int msg_nr = 0; pr_msg("\n"); while (msg_nr++ < e->qnum) - pb_show_plain_payload(fd, PB_IPCNS_MSG, ipc_msg_data_handler, - show_pages_content); + pb_show_plain_payload(fd, PB_IPCNS_MSG, ipc_msg_data_handler); } void show_ipc_msg(int fd, struct cr_options *o) { - pb_show_plain_payload(fd, PB_IPCNS_MSG_ENT, ipc_msg_handler, o->show_pages_content); + pb_show_plain_payload(fd, PB_IPCNS_MSG_ENT, ipc_msg_handler); } -static void ipc_shm_handler(int fd, void *obj, int show_pages_content) +static void ipc_shm_handler(int fd, void *obj) { IpcShmEntry *e = obj; - print_image_data(fd, round_up(e->size, sizeof(u32)), show_pages_content); + print_image_data(fd, round_up(e->size, sizeof(u32)), opts.show_pages_content); } void show_ipc_shm(int fd, struct cr_options *o) { - pb_show_plain_payload(fd, PB_IPCNS_SHM, ipc_shm_handler, - o->show_pages_content); + pb_show_plain_payload(fd, PB_IPCNS_SHM, ipc_shm_handler); } void show_ipc_var(int fd, struct cr_options *o) diff --git a/protobuf.c b/protobuf.c index 66b9d22bc..fba095318 100644 --- a/protobuf.c +++ b/protobuf.c @@ -505,14 +505,14 @@ static void pb_show_msg(const void *msg, pb_pr_ctl_t *ctl) } } -static inline void pb_no_payload(int fd, void *obj, int flags) { } +static inline void pb_no_payload(int fd, void *obj) { } void do_pb_show_plain(int fd, int type, int single_entry, - void (*payload_hadler)(int fd, void *obj, int flags), - int flags, const char *pretty_fmt) + void (*payload_hadler)(int fd, void *obj), + const char *pretty_fmt) { pb_pr_ctl_t ctl = {NULL, single_entry, pretty_fmt}; - void (*handle_payload)(int fd, void *obj, int flags); + void (*handle_payload)(int fd, void *obj); if (!cr_pb_descs[type].pb_desc) { pr_err("Wrong object requested %d\n", type); @@ -529,7 +529,7 @@ void do_pb_show_plain(int fd, int type, int single_entry, ctl.arg = (void *)cr_pb_descs[type].pb_desc; pb_show_msg(obj, &ctl); - handle_payload(fd, obj, flags); + handle_payload(fd, obj); cr_pb_descs[type].free(obj, NULL); if (single_entry) break; diff --git a/sk-queue.c b/sk-queue.c index 8676ba33f..647f87a17 100644 --- a/sk-queue.c +++ b/sk-queue.c @@ -170,16 +170,15 @@ err_brk: return ret; } -static void sk_queue_data_handler(int fd, void *obj, int show_pages_content) +static void sk_queue_data_handler(int fd, void *obj) { SkPacketEntry *e = obj; - print_image_data(fd, e->length, show_pages_content); + print_image_data(fd, e->length, opts.show_pages_content); } void show_sk_queues(int fd, struct cr_options *o) { - pb_show_plain_payload(fd, PB_SK_QUEUES, - sk_queue_data_handler, o->show_pages_content); + pb_show_plain_payload(fd, PB_SK_QUEUES, sk_queue_data_handler); } int restore_sk_queue(int fd, unsigned int peer_id)