static struct value *make_exn_lns_error(struct info *info, struct lns_error *err, const char *text) { struct value *v; if (HAS_ERR(info)) return exn_error(); v = make_exn_value(ref(info), "%s", err->message); if (err->lens != NULL) { char *s = format_info(err->lens->info); exn_printf_line(v, "Lens: %s", s); free(s); } if (err->pos >= 0) { char *pos = format_pos(text, err->pos); size_t line, ofs; calc_line_ofs(text, err->pos, &line, &ofs); exn_printf_line(v, "Error encountered at %d:%d (%d characters into string)", (int) line, (int) ofs, err->pos); if (pos != NULL) exn_printf_line(v, "%s", pos); free(pos); } else { exn_printf_line(v, "Error encountered at path %s", err->path); } return v; }
static void draw_text_info(int x, int y, int dx, int dy, int pos) { char buffer[3][256]; adv_crtc* crtc = menu_pos(pos); if (crtc) { format_info(buffer[0], buffer[1], buffer[2], 256, crtc); } else { sncpy(buffer[0], sizeof(buffer[0]), ""); sncpy(buffer[1], sizeof(buffer[1]), ""); sncpy(buffer[2], sizeof(buffer[2]), ""); } draw_text_left(x, y+0, dx, buffer[0], COLOR_INFO_TITLE); draw_text_left(x, y+1, dx, buffer[1], COLOR_INFO_NORMAL); draw_text_left(x, y+2, dx, buffer[2], COLOR_INFO_NORMAL); if (crtc) { if (crtc_is_fake(crtc)) { draw_text_left(x+dx-8, y, 8, " SYSTEM ", COLOR_INFO_NORMAL); } else if (!crtc_clock_check(&the_monitor, crtc)) { draw_text_left(x+dx-14, y, 14, " OUT OF RANGE ", COLOR_ERROR); } else { draw_text_left(x+dx-14, y, 14, " PROGRAMMABLE ", COLOR_INFO_NORMAL); } } else { draw_text_fillrect(x, y, ' ', dx, dy, COLOR_INFO_NORMAL); } }
static int do_dump(const char *req_name) { daemon_reply reply; int result; int fd, rv = 0; int count = 0; fd = setup_dump_socket(); if (fd < 0) { log_error("socket error %d", fd); return fd; } reply = daemon_send_simple(_lvmlockd, req_name, NULL); if (reply.error) { log_error("reply error %d", reply.error); rv = reply.error; goto out; } result = daemon_reply_int(reply, "result", 0); dump_len = daemon_reply_int(reply, "dump_len", 0); daemon_reply_destroy(reply); if (result < 0) { rv = result; log_error("result %d", result); } if (!dump_len) goto out; memset(dump_buf, 0, sizeof(dump_buf)); retry: rv = recvfrom(fd, dump_buf + count, dump_len - count, MSG_WAITALL, (struct sockaddr *)&dump_addr, &dump_addrlen); if (rv < 0) { log_error("recvfrom error %d %d", rv, errno); rv = -errno; goto out; } count += rv; if (count < dump_len) goto retry; rv = 0; if ((info && dump) || !strcmp(req_name, "dump")) printf("%s\n", dump_buf); else format_info(); out: if (close(fd)) log_error("failed to close dump socket %d", fd); return rv; }
static struct value *typecheck_union(struct info *info, struct lens *l1, struct lens *l2) { struct value *exn = NULL; exn = disjoint_check(info, "union.get", l1->ctype, l2->ctype); if (exn == NULL) { exn = disjoint_check(info, "tree union.put", l1->atype, l2->atype); } if (exn != NULL) { char *fi = format_info(l1->info); exn_printf_line(exn, "First lens: %s", fi); free(fi); fi = format_info(l2->info); exn_printf_line(exn, "Second lens: %s", fi); free(fi); } return exn; }
static struct value *typecheck_concat(struct info *info, struct lens *l1, struct lens *l2) { struct value *result = NULL; result = ambig_concat_check(info, "ambiguous concatenation", l1->ctype, l2->ctype); if (result == NULL) { result = ambig_concat_check(info, "ambiguous tree concatenation", l1->atype, l2->atype); } if (result != NULL) { char *fi = format_info(l1->info); exn_printf_line(result, "First lens: %s", fi); free(fi); fi = format_info(l2->info); exn_printf_line(result, "Second lens: %s", fi); free(fi); } return result; }
static struct value *typecheck_iter(struct info *info, struct lens *l) { struct value *result = NULL; result = ambig_iter_check(info, "ambiguous iteration", l->ctype); if (result == NULL) { result = ambig_iter_check(info, "ambiguous tree iteration", l->atype); } if (result != NULL) { char *fi = format_info(l->info); exn_printf_line(result, "Iterated lens: %s", fi); free(fi); } return result; }