bool SuifValidater::is_valid_SymbolTable(SymbolTable* symtab) { if (symtab == NULL) SUIF_THROW(SuifException(String("Cannot validate a NULL SymbolTable."))); bool ok_stat = true; {for (Iter<SymbolTable::lookup_table_pair> it = symtab->get_lookup_table_iterator(); it.is_valid(); it.next()) { if (!symtab->has_symbol_table_object_member(it.current().second)) { ok_stat = false; add_error(to_id_string(symtab) + " has a lookup pair <" + it.current().first + ", " + to_id_string(it.current().second) + "> with dangling object."); } }} {for (Iter<SymbolTableObject*> it = symtab->get_symbol_table_object_iterator(); it.is_valid(); it.next()) { SymbolTableObject *sobj = it.current(); if ((sobj->get_name().length() > 0) && !is_in_lookup_list(it.current(), symtab)) { ok_stat = false; add_error(to_id_string(symtab) + " has " + to_id_string(it.current()) + " not in lookup list."); } }} return ok_stat; }
void Media::upload_image_treat() { LOGIN_REQUIRED(); forms::media::UploadImage form; form.load(context()); form.image.load(context()); if (!form.validate()) { if (!form.image.validate()) { add_error(MEDIA_SAVE_INVALID_ERROR_TEXT); } go_back_to_previous_page(); return; } std::string fileURL = uploadsModel->save( form.image.value() ); if (fileURL.empty()) { add_error(MEDIA_SAVE_INTERNAL_ERROR_TEXT); go_back_to_previous_page(); return; } const std::string fileUploaded = (cppcms::locale::format( _("File uploaded successfully. at this address: {1} ") ) % fileURL).str(); add_success(fileUploaded); go_back_to_previous_page(); }
static struct list_head* __test_mv_inv(def_int_t *pStart, def_int_t *pEnd,int pIter, def_int_t pPattern) { struct list_head *errors = NULL; volatile def_int_t *cur = NULL; def_int_t *start = NULL, *end = NULL, pattern = 0, pattern_not = 0; int iter = 60,i = 0; start = pStart; end = pEnd; pattern = pPattern; pattern_not = ~pattern; iter = pIter; for (cur = start; cur < end; cur++) { #ifdef DEBUG printf("Testing:0x%x\n",(def_int_t)cur); #endif *cur = pattern; #ifdef CORRUPT /* we corrupt some memory */ *cur = *cur << 2; #endif } for (i = 0; i < iter; i++) { for (cur = start; cur < end; cur++) { if (*cur != pattern) { if (errors == NULL) { errors = init_list(); } add_error(errors,(def_int_t)start,sizeof(def_int_t)*(cur - start),pattern,(def_int_t)*cur); } *cur = pattern_not; } for (cur = end - 1; cur >= start; cur--) { if (*cur != pattern_not) { if (errors == NULL) { errors = init_list(); } add_error(errors,(def_int_t)start,sizeof(def_int_t)*(cur - start),pattern_not,(def_int_t)*cur); } *cur = pattern; } } return errors; }
// Reads the next UTF-8 character in the iter. // This assumes that iter->_start points to the beginning of the character. // When this method returns, iter->_width and iter->_current will be set // appropriately, as well as any error flags. static void read_char(Utf8Iterator* iter) { if (iter->_start >= iter->_end) { // No input left to consume; emit an EOF and set width = 0. iter->_current = -1; iter->_width = 0; return; } uint32_t code_point = 0; uint32_t state = UTF8_ACCEPT; for (const char* c = iter->_start; c < iter->_end; ++c) { decode(&state, &code_point, (uint32_t)(unsigned char) (*c)); if (state == UTF8_ACCEPT) { iter->_width = c - iter->_start + 1; // This is the special handling for carriage returns that is mandated by // the HTML5 spec. Since we're looking for particular 7-bit literal // characters, we operate in terms of chars and only need a check for iter // overrun, instead of having to read in a full next code point. // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#preprocessing-the-input-stream if (code_point == '\r') { assert(iter->_width == 1); const char* next = c + 1; if (next < iter->_end && *next == '\n') { // Advance the iter, as if the carriage return didn't exist. ++iter->_start; // Preserve the true offset, since other tools that look at it may be // unaware of HTML5's rules for converting \r into \n. ++iter->_pos.offset; } code_point = '\n'; } if (utf8_is_invalid_code_point(code_point)) { add_error(iter, GUMBO_ERR_UTF8_INVALID); code_point = kUtf8ReplacementChar; } iter->_current = code_point; return; } else if (state == UTF8_REJECT) { // We don't want to consume the invalid continuation byte of a multi-byte // run, but we do want to skip past an invalid first byte. iter->_width = c - iter->_start + (c == iter->_start); iter->_current = kUtf8ReplacementChar; add_error(iter, GUMBO_ERR_UTF8_INVALID); return; } } // If we got here without exiting early, then we've reached the end of the // iterator. Add an error for truncated input, set the width to consume the // rest of the iterator, and emit a replacement character. The next time we // enter this method, it will detect that there's no input to consume and // output an EOF. iter->_current = kUtf8ReplacementChar; iter->_width = iter->_end - iter->_start; add_error(iter, GUMBO_ERR_UTF8_TRUNCATED); }
static void worker_cb(int fd, short flags, void *arg) { struct Worker *w = arg; const char *err; char buf[128]; int res; size_t outlen; w->pending = 0; if (w->wstate == HANDSHAKE) { err = do_handshake(w, fd); add_error(w, err); } else if (w->wstate == CONNECTED) { if (flags & EV_READ) { res = tls_read(w->ctx, buf, sizeof buf, &outlen); if (res == TLS_READ_AGAIN) { wait_for_event(w, EV_READ); } else if (res == TLS_WRITE_AGAIN) { wait_for_event(w, EV_WRITE); } else if (res == 0) { if (outlen > 0 && w->is_server) { tls_write(w->ctx, "END", 3, &outlen); w->wstate = CLOSED; } else if (outlen == 0) { w->wstate = CLOSED; } else { wait_for_event(w, EV_READ); } } else { add_error(w, "bad pkt"); } } else { add_error(w, "EV_WRITE?"); } } if (w->wstate == CLOSED && w->ctx) { res = tls_close(w->ctx); if (res == 0) { tls_free(w->ctx); w->ctx = NULL; } else if (res == TLS_READ_AGAIN) { wait_for_event(w, EV_READ); } else if (res == TLS_WRITE_AGAIN) { wait_for_event(w, EV_WRITE); } else { tls_free(w->ctx); w->ctx = NULL; } } if (!w->pending && w->ctx) { errx(1, "missed event setup: %s flags=%d state=%d", w->is_server ? "S":"C", flags, w->wstate); } return; }
char parse_short_option(Arg_parser * ap, const char *const opt, const char *const arg, const ap_Option options[], int *argindp) { int cind = 1; // character index in opt while (cind > 0) { int index = -1; int i; const unsigned char code = opt[cind]; const char code_str[2] = { code, 0 }; if (code != 0) for (i = 0; options[i].code; ++i) if (code == options[i].code) { index = i; break; } if (index < 0) { add_error(ap, "invalid option -- "); add_error(ap, code_str); return 1; } if (opt[++cind] == 0) { ++*argindp; cind = 0; } // opt finished if (options[index].has_arg != ap_no && cind > 0 && opt[cind]) { if (!push_back_record(ap, code, &opt[cind])) return 0; ++*argindp; cind = 0; } else if (options[index].has_arg == ap_yes) { if (!arg || !arg[0]) { add_error(ap, "option requires an argument -- "); add_error(ap, code_str); return 1; } ++*argindp; cind = 0; if (!push_back_record(ap, code, arg)) return 0; } else if (!push_back_record(ap, code, "")) return 0; } return 1; }
Token *parse_arg_list(Token *beg_token, Token *last_token, Token **expression) { if (beg_token >= last_token) return beg_token; *expression = 0; Token *token = beg_token; if (!PAREN_OPEN(token)) return beg_token; u32 paren_level = 0; while (token <= last_token) { if (PAREN_OPEN(token)) ++paren_level; else if (PAREN_CLOSE(token)) { if (--paren_level == 0) break; } ++token; } if (paren_level) { add_error("Missing argument list end", last_token->end); return 0; } if ((token - beg_token) == 1) return token + 1; *expression = parse_expression(beg_token + 1, token - 1); return *expression ? token + 1 : 0; }
Status global_errors::add_error( Status subsystem, Status priorStatus, int lineno, const char *file, int error_index ) { char extra[strlen(file) + 10]; sprintf( extra, "%s:%d", file, lineno ); return add_error( new error_node(subsystem,priorStatus,error_index,extra) ); }
int unknown_cmd(t_info *all, t_word **word) { all->tete_error = add_error(all->tete_error, (*word)->word, ERR_CMD_UNDEFINE, (*word)->line); *word = (*word)->next; return (0); }
static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *input_error) { grpc_transport_stream_op_batch *batch = (grpc_transport_stream_op_batch *)arg; grpc_call_element *elem = batch->handler_private.extra_arg; call_data *calld = elem->call_data; reset_auth_metadata_context(&calld->auth_md_context); grpc_error *error = GRPC_ERROR_REF(input_error); if (error == GRPC_ERROR_NONE) { GPR_ASSERT(calld->md_array.size <= MAX_CREDENTIALS_METADATA_COUNT); GPR_ASSERT(batch->send_initial_metadata); grpc_metadata_batch *mdb = batch->payload->send_initial_metadata.send_initial_metadata; for (size_t i = 0; i < calld->md_array.size; ++i) { add_error(&error, grpc_metadata_batch_add_tail( exec_ctx, mdb, &calld->md_links[i], GRPC_MDELEM_REF(calld->md_array.md[i]))); } } if (error == GRPC_ERROR_NONE) { grpc_call_next_op(exec_ctx, elem, batch); } else { error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED); grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, batch, error); } }
/* Wird 15 mal ausgeführt */ struct list_head* test_random_numbers(def_int_t *pStart, def_int_t *pEnd) { struct list_head *errors = NULL; volatile def_int_t *cur = NULL; def_int_t *start = NULL, *end = NULL, seed = 0, num = 0; int i = 0; start = pStart; end = pEnd; seed = time(NULL); srand(seed); for (cur = start; cur < end; cur++) { #ifdef DEBUG printf("Testing:0x%x\n",(def_int_t)cur); #endif #if __WORDSIZE == 64 num = (def_int_t)rand(); num |= (def_int_t)rand() << 32; #else num = rand(); #endif *cur = num; } for (i = 0; i < 2; i++) { srand(seed); for (cur = start; cur < end; cur++) { #if __WORDSIZE == 64 num = (def_int_t)rand(); num |= (def_int_t)rand() << 32; #else num = rand(); #endif if (i == 1) { num = ~num; } if (*cur != num) { if (errors == NULL) { errors = init_list(); } add_error(errors,(def_int_t)start,sizeof(def_int_t)*(cur - start),num,(def_int_t)*cur); } *cur = ~num; #ifdef CORRUPT /* we corrupt some memory */ *cur = *cur << 2; #endif } } return errors; }
struct list_head* test_address_own(def_int_t *pStart,def_int_t *pEnd) { struct list_head *errors = NULL; volatile def_int_t *cur = NULL; def_int_t *start = NULL, *end = NULL; start = pStart; end = pEnd; for (cur = start; cur < end; cur++) { #ifdef DEBUG printf("Testing:0x%x\n",(def_int_t)cur); #endif *cur = (def_int_t)cur; /* we corrupt some memory */ /* *cur = *cur << 2;*/ } for (cur = start; cur < end; cur++) { if (*cur != (def_int_t)cur) { if (errors == NULL) { errors = init_list(); } add_error(errors,(def_int_t)start,sizeof(def_int_t)*(cur - start),(def_int_t)cur,*cur); } } return errors; }
void stat_cache::set_error(int const i, error_code const& ec) { TORRENT_ASSERT(i >= 0); if (i >= int(m_stat_cache.size())) m_stat_cache.resize(i + 1, not_in_cache); int error_index = add_error(ec); m_stat_cache[i].file_size = file_error - error_index; }
static const char *wait_for_event(struct Worker *w, short flags) { event_assign(&w->ev, w->evbase, w->socket, flags, worker_cb, w); tt_assert(event_add(&w->ev, NULL) == 0); w->pending = 1; return "OK"; end: return add_error(w, "event_add failed"); }
//Select the vertex pair at head of queue void YSlim::select_pair() { for(int i=0; i<adj.size(); ++i) { adj[i].clear(); } adj.clear(); vector<int> line; for(int i=0; i<vertices.size(); ++i) { adj.push_back(line); } while(!errors.empty()) errors.pop(); for(int i=0; i<faces.size(); ++i) { add_error(faces[i].id_vertex[0], faces[i].id_vertex[1]); add_error(faces[i].id_vertex[0], faces[i].id_vertex[2]); add_error(faces[i].id_vertex[1], faces[i].id_vertex[2]); } }
static uint64_t string2nsec(char *value) { uint64_t val = string_to_nsec(value); if (val == 0) { char err[1024]; snprintf(err, 1024, "Cannot convert %s to nsecs\n", value); add_error(err); } return (val); }
void errorfv(const char* file, const char* fmt, va_list ap) { char buf[LINE_LEN]; vsnprintf(buf, LINE_LEN, fmt, ap); errormsg_t* e = POOL_ALLOC(errormsg_t); memset(e, 0, sizeof(errormsg_t)); e->file = stringtab(file); e->msg = stringtab(buf); add_error(e); }
/* Check whether the chosen settings can successfully parse * the import data. This will check: * - there's at least one line selected for import * - the minimum number of columns is selected * - the values in the selected columns can be parsed meaningfully. * @return An empty string if all checks passed or the reason * verification failed otherwise. */ std::string GncTxImport::verify () { auto newline = std::string(); auto error_msg = ErrorList(); /* Check if the import file did actually contain any information */ if (m_parsed_lines.size() == 0) { error_msg.add_error(_("No valid data found in the selected file. It may be empty or the selected encoding is wrong.")); return error_msg.str(); } /* Check if at least one line is selected for importing */ auto skip_alt_offset = m_settings.m_skip_alt_lines ? 1 : 0; if (m_settings.m_skip_start_lines + m_settings.m_skip_end_lines + skip_alt_offset >= m_parsed_lines.size()) { error_msg.add_error(_("No lines are selected for importing. Please reduce the number of lines to skip.")); return error_msg.str(); } verify_column_selections (error_msg); update_skipped_lines (boost::none, boost::none, boost::none, boost::none); auto have_line_errors = false; for (auto line : m_parsed_lines) { if (!std::get<PL_SKIP>(line) && !std::get<PL_ERROR>(line).empty()) { have_line_errors = true; break; } } if (have_line_errors) error_msg.add_error( _("Not all fields could be parsed. Please correct the issues reported for each line or adjust the lines to skip.")); return error_msg.str(); }
static enum add_return add_object_path(lua_State *L, int index, DBusSignatureIter *type, DBusMessageIter *args) { const char *s; (void)type; if (!lua_isstring(L, index)) return add_error(L, index, LUA_TSTRING); s = lua_tostring(L, index); dbus_message_iter_append_basic(args, DBUS_TYPE_OBJECT_PATH, &s); return ADD_OK; }
static enum add_return add_boolean(lua_State *L, int index, DBusSignatureIter *type, DBusMessageIter *args) { dbus_bool_t b; (void)type; if (!lua_isboolean(L, index)) return add_error(L, index, LUA_TBOOLEAN); b = lua_toboolean(L, index); dbus_message_iter_append_basic(args, DBUS_TYPE_BOOLEAN, &b); return ADD_OK; }
static enum add_return add_byte(lua_State *L, int index, DBusSignatureIter *type, DBusMessageIter *args) { unsigned char n; (void)type; if (!lua_isnumber(L, index)) return add_error(L, index, LUA_TNUMBER); n = (unsigned char)lua_tonumber(L, index); dbus_message_iter_append_basic(args, DBUS_TYPE_BYTE, &n); return ADD_OK; }
static int string2int(char *value) { if (!value) { return (-1); } int val = string_to_int(value); if (val < 0) { char err[1024]; snprintf(err, 1024, "Cannot parse %s\n", value); add_error(err); } return (val); }
static enum add_return add_int16(lua_State *L, int index, DBusSignatureIter *type, DBusMessageIter *args) { dbus_int16_t n; (void)type; if (!lua_isnumber(L, index)) return add_error(L, index, LUA_TNUMBER); n = (dbus_int16_t)lua_tonumber(L, index); dbus_message_iter_append_basic(args, DBUS_TYPE_INT16, &n); return ADD_OK; }
static struct list_head* __test_mod(def_int_t *pStart, def_int_t *pEnd, def_int_t pPattern, int pOffset, int pIter) { struct list_head *errors = NULL; volatile def_int_t *cur = NULL; def_int_t *start = NULL, *end = NULL, pattern = 0, pattern_not = 0; int iter = 0,i = 0, k = 0; start = pStart; end = pEnd; pattern = pPattern; pattern_not = ~pattern; iter = pIter; for (cur = start + (def_int_t)pOffset; cur < end; cur += MOD_SZ) { *cur = pattern; } for (i = 0; i < iter; i++) { k = 0; for (cur = start; cur < end; cur++) { if (k != pOffset) { *cur = pattern_not; } if (++k > MOD_SZ-1) { k = 0; } } } for (cur = start + (def_int_t)pOffset; cur < end; cur += MOD_SZ) { if (*cur != pattern) { if (errors == NULL) { errors = init_list(); } add_error(errors,(def_int_t)start,sizeof(def_int_t)*(cur - start),pattern,(def_int_t)*cur); } } return errors; }
void Articles::remove(const std::string slug) { LOGIN_REQUIRED(); const bool success = articlesModel->remove( get_interface_lang(), slug ); if (success) { add_success(_("The article has been removed")); } else { add_error(_("A problem occured while trying to remove")); } go_to_main_page(); }
int preprocess(linkedlist* transformations) { lie_transfo_regle(transformations); cellule* ct=ll_front(transformations); while(ct!=NULL) { Transformation* t=(Transformation*)ct->valeur; cellule* cr=ll_front(&t->regles); while(cr!=NULL) { Regle* r=(Regle*)cr->valeur; r->minimum_taille=minimum_taille(&r->opcodes,ll_size(transformations),0); if(r->minimum_taille==NON_CALCULE) { snprintf(derniere_erreur,1024,"[ FATAL ] Recursion trop longue pour la transformation %s",t->nom); add_error(derniere_erreur); return 0; } r->nb_randint=0; r->nb_randmem=0; r->nb_randreg=0; r->nb_urandreg=0; r->nb_lab=0; r->nb_reg=0; r->nb_ureg=0; int i; for(i=0;i<10;i++) { r->randint_used[i]=0; r->randmem_used[i]=0; r->randreg_used[i]=0; r->urandreg_used[i]=0; r->reg_used[i]=0; r->ureg_used[i]=0; r->lab_used[i]=0; r->reg_locked[i]=0; r->randreg_locked[i]=0; r->randmem_locked[i]=0; } utilisation_rand_opcodes(&r->opcodes,r); cr=ll_next(&t->regles,cr); } ct=ll_next(transformations,ct); } return 1; }
void errorv(source_t* source, size_t line, size_t pos, const char* fmt, va_list ap) { char buf[LINE_LEN]; vsnprintf(buf, LINE_LEN, fmt, ap); errormsg_t* e = POOL_ALLOC(errormsg_t); memset(e, 0, sizeof(errormsg_t)); if(source != NULL) e->file = source->file; e->line = line; e->pos = pos; e->msg = stringtab(buf); if((source != NULL) && (line != 0)) { size_t tline = 1; size_t tpos = 0; while((tline < e->line) && (tpos < source->len)) { if(source->m[tpos] == '\n') tline++; tpos++; } size_t start = tpos; while((source->m[tpos] != '\n') && (tpos < source->len)) tpos++; size_t len = tpos - start; if(len >= sizeof(buf)) len = sizeof(buf) - 1; memcpy(buf, &source->m[start], len); buf[len] = '\0'; e->source = stringtab(buf); } add_error(e); }
/** * May or may not add a symbol, if line contains one. * Potentially catches a multiply defined symbol, returns the * integer of how much the location counter needs to increment. **/ int maybe_add_symbol(char *line, unsigned int lc, unsigned int ds, unsigned int ts, short second_pass) { char *label, *val; char *dupline = strdup(line); label = strtok(dupline, " \t"); if (label[strlen(label)-1] != ':') return 1; label[strlen(label)-1] = '\0'; // remove colon if (has_symbol(label) && second_pass == 0) { add_error(ln, 'M', label); // multiply defined symbol } else if (label != NULL && !has_symbol(label)) { if (num_symbols >= MIN_SYMTABLE_LENGTH) { symbol_table = realloc(symbol_table, (num_symbols * REALLOC_MULTIPLIER) * sizeof(symbol *)); } symbol_table[num_symbols] = malloc(sizeof(symbol)); symbol_table[num_symbols]->name = strdup(label); symbol_table[num_symbols]->lc = lc; num_symbols++; } if (ds) { // data segment needs additional parsing val = strtok(NULL, " \t\n"); if (strcmp(val, WORD_DIRECTIVE) == 0) { val = strtok(NULL, " \t\n"); val = strtok(val, ":"); val = strtok(NULL, ":"); return atoi(val); } else if (strcmp(val, RESW_DIRECTIVE) == 0) { val = strtok(NULL, " \t\n"); return atoi(val); } } return 1; }
static enum add_return add_array(lua_State *L, int index, DBusSignatureIter *type, DBusMessageIter *args) { DBusSignatureIter array_type; DBusMessageIter array_args; char *signature; add_function af; int i; if (!lua_istable(L, index)) return add_error(L, index, LUA_TTABLE); dbus_signature_iter_recurse(type, &array_type); signature = dbus_signature_iter_get_signature(&array_type); dbus_message_iter_open_container(args, DBUS_TYPE_ARRAY, signature, &array_args); af = get_addfunc(&array_type); i = 1; while (1) { lua_rawgeti(L, index, i); if (lua_isnil(L, -1)) break; if (af(L, -1, &array_type, &array_args) != ADD_OK) { lua_insert(L, -2); lua_pop(L, 1); return ADD_ERROR; } lua_pop(L, 1); i++; } lua_pop(L, 1); dbus_free(signature); dbus_message_iter_close_container(args, &array_args); return ADD_OK; }
void Articles::translate(const std::string slug) { LOGIN_REQUIRED(); int articleToTranslateId = articlesModel->get_id_from_lang_and_slug( get_interface_lang(), slug ); if (articleToTranslateId == ARTICLE_DOESNT_EXIST_ERROR) { add_error(_("The article you try to translate does not exist.")); go_back_to_previous_page(); return; } contents::articles::Translate c(slug); init_content(c); render("articles_translate", c); }