From 41c3c0f8b1b8e58441535bb3abab67122abf5137 Mon Sep 17 00:00:00 2001 From: Rodrigo Kumpera Date: Sun, 13 Jan 2019 23:34:20 -0500 Subject: [PATCH] Fix unused params warnings plus incomplete struct init (done to default values). --- explore/explore_internal.h | 12 +-- vowpalwabbit/OjaNewton.cc | 2 +- vowpalwabbit/active_cover.cc | 2 +- vowpalwabbit/array_parameters.h | 2 +- vowpalwabbit/audit_regressor.cc | 6 +- vowpalwabbit/bfgs.cc | 16 +-- vowpalwabbit/boosting.cc | 8 +- vowpalwabbit/cache.cc | 16 +-- vowpalwabbit/cb.cc | 10 +- vowpalwabbit/cb_explore.cc | 2 +- vowpalwabbit/cb_explore_adf.cc | 4 +- vowpalwabbit/confidence.cc | 4 +- vowpalwabbit/cost_sensitive.cc | 6 +- vowpalwabbit/example.cc | 2 +- vowpalwabbit/ftrl.cc | 2 +- vowpalwabbit/gd.cc | 24 ++--- vowpalwabbit/gen_cs_example.cc | 2 +- vowpalwabbit/global_data.h | 2 +- vowpalwabbit/io_buf.cc | 52 +++++----- vowpalwabbit/io_buf.h | 116 ++++++++++++---------- vowpalwabbit/kernel_svm.cc | 22 ++-- vowpalwabbit/lda_core.cc | 14 +-- vowpalwabbit/log_multi.cc | 2 +- vowpalwabbit/loss_functions.cc | 6 +- vowpalwabbit/multiclass.cc | 4 +- vowpalwabbit/multilabel.cc | 6 +- vowpalwabbit/no_label.cc | 16 +-- vowpalwabbit/parse_example_json.h | 28 +++--- vowpalwabbit/parse_regressor.cc | 20 ++-- vowpalwabbit/parser.cc | 3 +- vowpalwabbit/parser_helper.h | 2 +- vowpalwabbit/print.cc | 2 +- vowpalwabbit/recall_tree.cc | 2 +- vowpalwabbit/search.cc | 4 +- vowpalwabbit/search_dep_parser.cc | 8 +- vowpalwabbit/search_entityrelationtask.cc | 2 +- vowpalwabbit/search_sequencetask.cc | 4 +- vowpalwabbit/simple_label.cc | 4 +- 38 files changed, 225 insertions(+), 214 deletions(-) diff --git a/explore/explore_internal.h b/explore/explore_internal.h index fa212e4437f..f46902001ba 100644 --- a/explore/explore_internal.h +++ b/explore/explore_internal.h @@ -35,7 +35,7 @@ namespace exploration } template - int generate_epsilon_greedy(float epsilon, uint32_t top_action, It pdf_first, It pdf_last, std::random_access_iterator_tag pdf_tag) + int generate_epsilon_greedy(float epsilon, uint32_t top_action, It pdf_first, It pdf_last, std::random_access_iterator_tag /* pdf_tag */) { if (pdf_last < pdf_first) return E_EXPLORATION_BAD_RANGE; @@ -65,7 +65,7 @@ namespace exploration } template - int generate_softmax(float lambda, InputIt scores_first, InputIt scores_last, std::input_iterator_tag scores_tag, OutputIt pdf_first, OutputIt pdf_last, std::random_access_iterator_tag pdf_tag) + int generate_softmax(float lambda, InputIt scores_first, InputIt scores_last, std::input_iterator_tag /* scores_tag */, OutputIt pdf_first, OutputIt pdf_last, std::random_access_iterator_tag /* pdf_tag */) { if (scores_last < scores_first || pdf_last < pdf_first) return E_EXPLORATION_BAD_RANGE; @@ -118,7 +118,7 @@ namespace exploration } template - int generate_bag(InputIt top_actions_first, InputIt top_actions_last, std::input_iterator_tag top_actions_tag, OutputIt pdf_first, OutputIt pdf_last, std::random_access_iterator_tag pdf_tag) + int generate_bag(InputIt top_actions_first, InputIt top_actions_last, std::input_iterator_tag /* top_actions_tag */, OutputIt pdf_first, OutputIt pdf_last, std::random_access_iterator_tag /* pdf_tag */) { // iterators don't support <= in general if (pdf_first == pdf_last || pdf_last < pdf_first) @@ -154,7 +154,7 @@ namespace exploration } template - int enforce_minimum_probability(float minimum_uniform, bool update_zero_elements, It pdf_first, It pdf_last, std::random_access_iterator_tag pdf_tag) + int enforce_minimum_probability(float minimum_uniform, bool update_zero_elements, It pdf_first, It pdf_last, std::random_access_iterator_tag /* pdf_tag */) { // iterators don't support <= in general if (pdf_first == pdf_last || pdf_last < pdf_first) @@ -230,7 +230,7 @@ namespace exploration } template - int sample_after_normalizing(uint64_t seed, It pdf_first, It pdf_last, uint32_t& chosen_index, std::input_iterator_tag pdf_category) + int sample_after_normalizing(uint64_t seed, It pdf_first, It pdf_last, uint32_t& chosen_index, std::input_iterator_tag /* pdf_category */) { if (pdf_first == pdf_last || pdf_last < pdf_first) return E_EXPLORATION_BAD_RANGE; @@ -299,7 +299,7 @@ namespace exploration } template - int swap_chosen(ActionIt action_first, ActionIt action_last, std::forward_iterator_tag action_category, uint32_t chosen_index) + int swap_chosen(ActionIt action_first, ActionIt action_last, std::forward_iterator_tag /* action_category */, uint32_t chosen_index) { if ( action_last < action_first ) return E_EXPLORATION_BAD_RANGE; diff --git a/vowpalwabbit/OjaNewton.cc b/vowpalwabbit/OjaNewton.cc index d22b92e83d3..8d8925c3d8a 100644 --- a/vowpalwabbit/OjaNewton.cc +++ b/vowpalwabbit/OjaNewton.cc @@ -342,7 +342,7 @@ struct OjaNewton } }; -void keep_example(vw& all, OjaNewton& ON, example& ec) +void keep_example(vw& all, OjaNewton& /* ON */, example& ec) { output_and_account_example(all, ec); } diff --git a/vowpalwabbit/active_cover.cc b/vowpalwabbit/active_cover.cc index 0e567e38a13..e5e79da5e1a 100644 --- a/vowpalwabbit/active_cover.cc +++ b/vowpalwabbit/active_cover.cc @@ -24,7 +24,7 @@ struct active_cover LEARNER::base_learner* l; }; -bool dis_test(vw& all, example& ec, single_learner& base, float prediction, float threshold) +bool dis_test(vw& all, example& ec, single_learner& base, float /* prediction */, float threshold) { if(all.sd->t + ec.weight <= 3) { diff --git a/vowpalwabbit/array_parameters.h b/vowpalwabbit/array_parameters.h index c014c28d74e..2db5010fab2 100644 --- a/vowpalwabbit/array_parameters.h +++ b/vowpalwabbit/array_parameters.h @@ -174,7 +174,7 @@ class sparse_parameters } #ifndef _WIN32 - void share(size_t length) + void share(size_t /* length */) {throw 1; //TODO: add better exceptions } #endif diff --git a/vowpalwabbit/audit_regressor.cc b/vowpalwabbit/audit_regressor.cc index 409cd76d287..d9bc75d71d0 100644 --- a/vowpalwabbit/audit_regressor.cc +++ b/vowpalwabbit/audit_regressor.cc @@ -63,12 +63,12 @@ inline void audit_regressor_feature(audit_regressor_data& dat, const float, cons if (dat.total_class_cnt > 1) // add class prefix for multiclass problems temp = to_string(dat.cur_class) + ':' + temp; - bin_write_fixed(*dat.out_file, temp.c_str(), (uint32_t)temp.size()); + dat.out_file->bin_write_fixed(temp.c_str(), (uint32_t)temp.size()); weights[ft_idx] = 0.; //mark value audited } -void audit_regressor_lda(audit_regressor_data& rd, LEARNER::single_learner& base, example& ec) +void audit_regressor_lda(audit_regressor_data& rd, LEARNER::single_learner& /* base */, example& ec) { vw& all = *rd.all; @@ -90,7 +90,7 @@ void audit_regressor_lda(audit_regressor_data& rd, LEARNER::single_learner& base } } - bin_write_fixed(*rd.out_file, tempstream.str().c_str(), (uint32_t)tempstream.str().size()); + rd.out_file->bin_write_fixed(tempstream.str().c_str(), (uint32_t)tempstream.str().size()); } diff --git a/vowpalwabbit/bfgs.cc b/vowpalwabbit/bfgs.cc index a86d7f61da1..15d47ec0cf4 100644 --- a/vowpalwabbit/bfgs.cc +++ b/vowpalwabbit/bfgs.cc @@ -174,7 +174,7 @@ float dot_with_direction(vw& all, example& ec) } template -double regularizer_direction_magnitude(vw& all, bfgs& b, double regularizer, T& weights) +double regularizer_direction_magnitude(vw& /* all */, bfgs& b, double regularizer, T& weights) { double ret = 0.; if (b.regularizers == nullptr) @@ -204,7 +204,7 @@ double regularizer_direction_magnitude(vw& all, bfgs& b, float regularizer) } template -float direction_magnitude(vw& all, T& weights) +float direction_magnitude(vw& /* all */, T& weights) { //compute direction magnitude double ret = 0.; @@ -480,7 +480,7 @@ double add_regularization(vw& all, bfgs& b, float regularization) } template -void finalize_preconditioner(vw& all, bfgs& b, float regularization, T& weights) +void finalize_preconditioner(vw& /* all */, bfgs& b, float regularization, T& weights) { float max_hessian = 0.f; @@ -558,7 +558,7 @@ void preconditioner_to_regularizer(vw& all, bfgs& b, float regularization) } template -void regularizer_to_weight(vw& all, bfgs& b, T& weights) +void regularizer_to_weight(vw& /* all */, bfgs& b, T& weights) { if (b.regularizers != nullptr) { @@ -587,7 +587,7 @@ void zero_state(vw& all) } template -double derivative_in_direction(vw& all, bfgs& b, float* mem, int &origin, T& weights) +double derivative_in_direction(vw& /* all */, bfgs& b, float* mem, int &origin, T& weights) { double ret = 0.; for (typename T::iterator w = weights.begin(); w != weights.end(); ++w) @@ -608,7 +608,7 @@ double derivative_in_direction(vw& all, bfgs& b, float* mem, int &origin) } template -void update_weight(vw& all, float step_size, T& w) +void update_weight(vw& /* all */, float step_size, T& w) { for (typename T::iterator iter = w.begin(); iter != w.end(); ++iter) (&(*iter))[W_XT] += step_size * (&(*iter))[W_DIR]; @@ -976,12 +976,12 @@ void save_load_regularizer(vw& all, bfgs& b, io_buf& model_file, bool read, bool if (read) { c++; - brw = bin_read_fixed(model_file, (char*)&i, sizeof(i),""); + brw = model_file.bin_read_fixed((char*)&i, sizeof(i),""); if (brw > 0) { assert (i< length); v = &(b.regularizers[i]); - brw += bin_read_fixed(model_file, (char*)v, sizeof(*v), ""); + brw += model_file.bin_read_fixed((char*)v, sizeof(*v), ""); } } else // write binary or text diff --git a/vowpalwabbit/boosting.cc b/vowpalwabbit/boosting.cc index 46a24295f0f..43ad5703115 100644 --- a/vowpalwabbit/boosting.cc +++ b/vowpalwabbit/boosting.cc @@ -287,7 +287,7 @@ void save_load_sampling(boosting &o, io_buf &model_file, bool read, bool text) if (read) { float f; - bin_read_fixed(model_file, (char *) &f, sizeof(f), ""); + model_file.bin_read_fixed((char *) &f, sizeof(f), ""); o.alpha[i] = f; } else @@ -301,7 +301,7 @@ void save_load_sampling(boosting &o, io_buf &model_file, bool read, bool text) if (read) { float f; - bin_read_fixed(model_file, (char *) &f, sizeof(f), ""); + model_file.bin_read_fixed((char *) &f, sizeof(f), ""); o.v[i] = f; } else @@ -332,7 +332,7 @@ void finish(boosting& o) o.alpha.~vector(); } -void return_example(vw& all, boosting& a, example& ec) +void return_example(vw& all, boosting& /* a */, example& ec) { output_and_account_example(all, ec); VW::finish_example(all,ec); @@ -354,7 +354,7 @@ void save_load(boosting &o, io_buf &model_file, bool read, bool text) if (read) { float f; - bin_read_fixed(model_file, (char *) &f, sizeof(f), ""); + model_file.bin_read_fixed((char *) &f, sizeof(f), ""); o.alpha[i] = f; } else diff --git a/vowpalwabbit/cache.cc b/vowpalwabbit/cache.cc index 6b986650183..f2a7590a804 100644 --- a/vowpalwabbit/cache.cc +++ b/vowpalwabbit/cache.cc @@ -43,12 +43,12 @@ size_t read_cached_tag(io_buf& cache, example* ae) { char* c; size_t tag_size; - if (buf_read(cache, c, sizeof(tag_size)) < sizeof(tag_size)) + if (cache.buf_read(c, sizeof(tag_size)) < sizeof(tag_size)) return 0; tag_size = *(size_t*)c; c += sizeof(tag_size); cache.set(c); - if (buf_read(cache, c, tag_size) < tag_size) + if (cache.buf_read(c, tag_size) < tag_size) return 0; ae->tag.clear(); @@ -75,7 +75,7 @@ int read_cached_features(vw* all, v_array& examples) return 0; char* c; unsigned char num_indices = 0; - if (buf_read(*input, c, sizeof(num_indices)) < sizeof(num_indices)) + if (input->buf_read(c, sizeof(num_indices)) < sizeof(num_indices)) return 0; num_indices = *(unsigned char*)c; c += sizeof(num_indices); @@ -85,7 +85,7 @@ int read_cached_features(vw* all, v_array& examples) { size_t temp; unsigned char index = 0; - if((temp = buf_read(*input,c,sizeof(index) + sizeof(size_t))) < sizeof(index) + sizeof(size_t)) + if((temp = input->buf_read(c,sizeof(index) + sizeof(size_t))) < sizeof(index) + sizeof(size_t)) { all->trace_message << "truncated example! " << temp << " " << char_size + sizeof(size_t) << endl; return 0; @@ -99,7 +99,7 @@ int read_cached_features(vw* all, v_array& examples) c += sizeof(size_t); all->p->input->set(c); total += storage; - if (buf_read(*input,c,storage) < storage) + if (input->buf_read(c,storage) < storage) { all->trace_message << "truncated example! wanted: " << storage << " bytes" << endl; return 0; @@ -145,7 +145,7 @@ void output_byte(io_buf& cache, unsigned char s) { char *c; - buf_write(cache, c, 1); + cache.buf_write(c, 1); *(c++) = s; cache.set(c); } @@ -158,7 +158,7 @@ void output_features(io_buf& cache, unsigned char index, features& fs, uint64_t if (f != 1. && f != -1.) storage += sizeof(feature_value); - buf_write(cache, c, sizeof(index) + storage + sizeof(size_t)); + cache.buf_write(c, sizeof(index) + storage + sizeof(size_t)); *reinterpret_cast(c) = index; c += sizeof(index); @@ -192,7 +192,7 @@ void output_features(io_buf& cache, unsigned char index, features& fs, uint64_t void cache_tag(io_buf& cache, v_array tag) { char *c; - buf_write(cache, c, sizeof(size_t)+tag.size()); + cache.buf_write(c, sizeof(size_t)+tag.size()); *(size_t*)c = tag.size(); c += sizeof(size_t); memcpy(c, tag.begin(), tag.size()); diff --git a/vowpalwabbit/cb.cc b/vowpalwabbit/cb.cc index ab86f8736b9..1626423fc0a 100644 --- a/vowpalwabbit/cb.cc +++ b/vowpalwabbit/cb.cc @@ -21,7 +21,7 @@ char* bufread_label(CB::label* ld, char* c, io_buf& cache) ld->costs.clear(); c += sizeof(size_t); size_t total = sizeof(cb_class)*num; - if (buf_read(cache, c, total) < total) + if (cache.buf_read(c, total) < total) { cout << "error in demarshal of cost data" << endl; return c; @@ -42,7 +42,7 @@ size_t read_cached_label(shared_data*, void* v, io_buf& cache) ld->costs.clear(); char *c; size_t total = sizeof(size_t); - if (buf_read(cache, c, total) < total) + if (cache.buf_read(c, total) < total) return 0; bufread_label(ld,c, cache); @@ -70,7 +70,7 @@ void cache_label(void* v, io_buf& cache) { char *c; CB::label* ld = (CB::label*) v; - buf_write(cache, c, sizeof(size_t)+sizeof(cb_class)*ld->costs.size()); + cache.buf_write(c, sizeof(size_t)+sizeof(cb_class)*ld->costs.size()); bufcache_label(ld,c); } @@ -226,7 +226,7 @@ size_t read_cached_label(shared_data*sd, void* v, io_buf& cache) CB_EVAL::label* ld = (CB_EVAL::label*) v; char* c; size_t total = sizeof(uint32_t); - if (buf_read(cache, c, total) < total) + if (cache.buf_read(c, total) < total) return 0; ld->action = *(uint32_t*)c; @@ -237,7 +237,7 @@ void cache_label(void* v, io_buf& cache) { char *c; CB_EVAL::label* ld = (CB_EVAL::label*) v; - buf_write(cache, c, sizeof(uint32_t)); + cache.buf_write(c, sizeof(uint32_t)); *(uint32_t *)c = ld->action; CB::cache_label(&(ld->event), cache); diff --git a/vowpalwabbit/cb_explore.cc b/vowpalwabbit/cb_explore.cc index 5cb58f303c4..c5fe05b9987 100644 --- a/vowpalwabbit/cb_explore.cc +++ b/vowpalwabbit/cb_explore.cc @@ -120,7 +120,7 @@ void predict_or_learn_bag(cb_explore& data, single_learner& base, example& ec) ec.pred.a_s = probs; } -void get_cover_probabilities(cb_explore& data, single_learner& base, example& ec, v_array& probs) +void get_cover_probabilities(cb_explore& data, single_learner& /* base */, example& ec, v_array& probs) { float additive_probability = 1.f / (float)data.cover_size; data.preds.clear(); diff --git a/vowpalwabbit/cb_explore_adf.cc b/vowpalwabbit/cb_explore_adf.cc index d7e2efd50dd..51c9adcba48 100644 --- a/vowpalwabbit/cb_explore_adf.cc +++ b/vowpalwabbit/cb_explore_adf.cc @@ -224,7 +224,7 @@ void get_cost_ranges(std::vector &min_costs, } } -size_t fill_tied(cb_explore_adf& data, v_array& preds) +size_t fill_tied(cb_explore_adf& /* data */, v_array& preds) { if (preds.size() == 0 ) return 0; @@ -581,7 +581,7 @@ void finish(cb_explore_adf& data) data.prepped_cs_labels[i].costs.delete_v(); data.prepped_cs_labels.delete_v(); data.gen_cs.pred_scores.costs.delete_v(); - data.gen_cs.mtr_ec_seq.~vector(); + data.gen_cs.mtr_ec_seq.~vector(); } diff --git a/vowpalwabbit/confidence.cc b/vowpalwabbit/confidence.cc index cc457b5e54b..354f1977823 100644 --- a/vowpalwabbit/confidence.cc +++ b/vowpalwabbit/confidence.cc @@ -7,7 +7,7 @@ using namespace std; struct confidence { vw* all;}; template -void predict_or_learn_with_confidence(confidence& c, single_learner& base, example& ec) +void predict_or_learn_with_confidence(confidence& /* c */, single_learner& base, example& ec) { float threshold = 0.f; float sensitivity = 0.f; @@ -62,7 +62,7 @@ void output_and_account_confidence_example(vw& all, example& ec) print_update(all, ec); } -void return_confidence_example(vw& all, confidence& c, example& ec) +void return_confidence_example(vw& all, confidence& /* c */, example& ec) { output_and_account_confidence_example(all, ec); VW::finish_example(all,ec); diff --git a/vowpalwabbit/cost_sensitive.cc b/vowpalwabbit/cost_sensitive.cc index 80e8e5c4438..20514760dc0 100644 --- a/vowpalwabbit/cost_sensitive.cc +++ b/vowpalwabbit/cost_sensitive.cc @@ -35,7 +35,7 @@ char* bufread_label(label* ld, char* c, io_buf& cache) ld->costs.clear(); c += sizeof(size_t); size_t total = sizeof(wclass)*num; - if (buf_read(cache, c, (int)total) < total) + if (cache.buf_read(c, (int)total) < total) { cout << "error in demarshal of cost data" << endl; return c; @@ -56,7 +56,7 @@ size_t read_cached_label(shared_data*, void* v, io_buf& cache) ld->costs.clear(); char *c; size_t total = sizeof(size_t); - if (buf_read(cache, c, (int)total) < total) + if (cache.buf_read(c, (int)total) < total) return 0; bufread_label(ld,c, cache); @@ -84,7 +84,7 @@ void cache_label(void* v, io_buf& cache) { char *c; label* ld = (label*) v; - buf_write(cache, c, sizeof(size_t)+sizeof(wclass)*ld->costs.size()); + cache.buf_write(c, sizeof(size_t)+sizeof(wclass)*ld->costs.size()); bufcache_label(ld,c); } diff --git a/vowpalwabbit/example.cc b/vowpalwabbit/example.cc index 9f3864ae546..52c98665953 100644 --- a/vowpalwabbit/example.cc +++ b/vowpalwabbit/example.cc @@ -43,7 +43,7 @@ void copy_example_label(example* dst, example* src, size_t, void(*copy_label)(vo dst->l = src->l; } -void copy_example_metadata(bool audit, example* dst, example* src) +void copy_example_metadata(bool /* audit */, example* dst, example* src) { copy_array(dst->tag, src->tag); dst->example_counter = src->example_counter; diff --git a/vowpalwabbit/ftrl.cc b/vowpalwabbit/ftrl.cc index 387304fd84b..679e6137efd 100644 --- a/vowpalwabbit/ftrl.cc +++ b/vowpalwabbit/ftrl.cc @@ -59,7 +59,7 @@ inline void predict_with_confidence(uncertainty& d, const float fx, float& fw) d.score += (1/uncertain)*sign(fx); } -float sensitivity(ftrl& b, base_learner& base, example& ec) +float sensitivity(ftrl& b, base_learner& /* base */, example& ec) { uncertainty uncetain(b); GD::foreach_feature(*(b.all), ec, uncetain); diff --git a/vowpalwabbit/gd.cc b/vowpalwabbit/gd.cc index ce1361c5000..0074cab0a97 100644 --- a/vowpalwabbit/gd.cc +++ b/vowpalwabbit/gd.cc @@ -549,7 +549,7 @@ float get_pred_per_update(gd& g, example& ec) if (grad_squared == 0 && !stateless) return 1.; - norm_data nd = {grad_squared, 0., 0., {g.neg_power_t, g.neg_norm_power}}; + norm_data nd = {grad_squared, 0., 0., {g.neg_power_t, g.neg_norm_power}, { 0 }}; foreach_feature >(all, ec, nd); if(normalized) { @@ -580,7 +580,7 @@ float sensitivity(gd& g, example& ec) } template -float get_scale(gd& g, example& ec, float weight) +float get_scale(gd& g, example& /* ec */, float weight) { float update_scale = g.all->eta * weight; if(!adaptive) @@ -592,7 +592,7 @@ float get_scale(gd& g, example& ec, float weight) } template -float sensitivity(gd& g, base_learner& base, example& ec) +float sensitivity(gd& g, base_learner& /* base */, example& ec) { return get_scale(g, ec, 1.) * sensitivity(g,ec); @@ -710,17 +710,17 @@ void save_load_regressor(vw& all, io_buf& model_file, bool read, bool text, T& w brw = 1; if (all.num_bits < 31)//backwards compatible { - brw = bin_read_fixed(model_file, (char*)&old_i, sizeof(old_i), ""); + brw = model_file.bin_read_fixed((char*)&old_i, sizeof(old_i), ""); i = old_i; } else - brw = bin_read_fixed(model_file, (char*)&i, sizeof(i), ""); + brw = model_file.bin_read_fixed((char*)&i, sizeof(i), ""); if (brw > 0) { if (i >= length) THROW("Model content is corrupted, weight vector index " << i << " must be less than total vector length " << length); weight* v = &weights.strided_index(i); - brw += bin_read_fixed(model_file, (char*)&(*v), sizeof(*v), ""); + brw += model_file.bin_read_fixed((char*)&(*v), sizeof(*v), ""); } } while (brw >0); @@ -769,22 +769,22 @@ void save_load_online_state(vw& all, io_buf& model_file, bool read, bool text, g brw = 1; if (all.num_bits < 31)//backwards compatible { - brw = bin_read_fixed(model_file, (char*)&old_i, sizeof(old_i), ""); + brw = model_file.bin_read_fixed((char*)&old_i, sizeof(old_i), ""); i = old_i; } else - brw = bin_read_fixed(model_file, (char*)&i, sizeof(i), ""); + brw = model_file.bin_read_fixed((char*)&i, sizeof(i), ""); if (brw > 0) { if (i >= length) THROW("Model content is corrupted, weight vector index " << i << " must be less than total vector length " << length); weight buff[4] = {0,0,0,0}; if (g == NULL || (!g->adaptive && !g->normalized)) - brw += bin_read_fixed(model_file, (char*)buff, sizeof(buff[0]), ""); + brw += model_file.bin_read_fixed((char*)buff, sizeof(buff[0]), ""); else if ((g->adaptive && !g->normalized) || (!g->adaptive && g->normalized)) - brw += bin_read_fixed(model_file, (char*)buff, sizeof(buff[0]) * 2, ""); + brw += model_file.bin_read_fixed((char*)buff, sizeof(buff[0]) * 2, ""); else //adaptive and normalized - brw += bin_read_fixed(model_file, (char*)buff, sizeof(buff[0]) * 3, ""); + brw += model_file.bin_read_fixed((char*)buff, sizeof(buff[0]) * 3, ""); uint32_t stride = 1 << weights.stride_shift(); weight* v = &weights.strided_index(i); for (size_t i = 0; i < stride; i++) @@ -942,7 +942,7 @@ void save_load_online_state(vw& all, io_buf& model_file, bool read, bool text, g template class set_initial_gd_wrapper { public: - static void func(weight& w, pair& initial, uint64_t index) + static void func(weight& w, pair& initial, uint64_t /* index */) { w = initial.first; (&w)[1] = initial.second; diff --git a/vowpalwabbit/gen_cs_example.cc b/vowpalwabbit/gen_cs_example.cc index 97eb548269c..323e4d265f1 100644 --- a/vowpalwabbit/gen_cs_example.cc +++ b/vowpalwabbit/gen_cs_example.cc @@ -173,7 +173,7 @@ void gen_cs_example_mtr(cb_to_cs_adf& c, multi_ex& ec_seq, COST_SENSITIVE::label { CB::label ld = ec_seq[i]->l.cb; - COST_SENSITIVE::wclass wc = {0, 0}; + COST_SENSITIVE::wclass wc = {0, 0, 0, 0}; bool keep_example = false; if (shared && i == 0) diff --git a/vowpalwabbit/global_data.h b/vowpalwabbit/global_data.h index 4033576db93..f2658b95085 100644 --- a/vowpalwabbit/global_data.h +++ b/vowpalwabbit/global_data.h @@ -137,7 +137,7 @@ struct dictionary_info feature_dict* dict; }; -inline void deleter(substring ss, uint64_t label) +inline void deleter(substring ss, uint64_t /* label */) { free_it(ss.begin); } class namedlabels diff --git a/vowpalwabbit/io_buf.cc b/vowpalwabbit/io_buf.cc index 2a7ced11f07..33a63febed3 100644 --- a/vowpalwabbit/io_buf.cc +++ b/vowpalwabbit/io_buf.cc @@ -9,35 +9,35 @@ license as described in the file LICENSE. #include #endif -size_t buf_read(io_buf &i, char* &pointer, size_t n) +size_t io_buf::buf_read(char* &pointer, size_t n) { //return a pointer to the next n bytes. n must be smaller than the maximum size. - if (i.head + n <= i.space.end()) + if (head + n <= space.end()) { - pointer = i.head; - i.head += n; + pointer = head; + head += n; return n; } else // out of bytes, so refill. { - if (i.head != i.space.begin()) //There exists room to shift. + if (head != space.begin()) //There exists room to shift. { // Out of buffer so swap to beginning. - size_t left = i.space.end() - i.head; - memmove(i.space.begin(), i.head, left); - i.head = i.space.begin(); - i.space.end() = i.space.begin() + left; + size_t left = space.end() - head; + memmove(space.begin(), head, left); + head = space.begin(); + space.end() = space.begin() + left; } - if (i.fill(i.files[i.current]) > 0) // read more bytes from current file if present - return buf_read(i, pointer, n);// more bytes are read. - else if (++i.current < i.files.size()) - return buf_read(i, pointer, n);// No more bytes, so go to next file and try again. + if (fill(files[current]) > 0) // read more bytes from current file if present + return buf_read(pointer, n);// more bytes are read. + else if (++current < files.size()) + return buf_read(pointer, n);// No more bytes, so go to next file and try again. else { //no more bytes to read, return all that we have left. - pointer = i.head; - i.head = i.space.end(); - return i.space.end() - pointer; + pointer = head; + head = space.end(); + return space.end() - pointer; } } } @@ -92,25 +92,25 @@ size_t readto(io_buf &i, char* &pointer, char terminal) } } -void buf_write(io_buf &o, char* &pointer, size_t n) +void io_buf::buf_write(char* &pointer, size_t n) { //return a pointer to the next n bytes to write into. - if (o.head + n <= o.space.end_array) + if (head + n <= space.end_array) { - pointer = o.head; - o.head += n; + pointer = head; + head += n; } else // Time to dump the file { - if (o.head != o.space.begin()) - o.flush(); + if (head != space.begin()) + flush(); else // Array is short, so increase size. { - o.space.resize(2*(o.space.end_array - o.space.begin())); - o.space.end() = o.space.begin(); - o.head = o.space.begin(); + space.resize(2*(space.end_array - space.begin())); + space.end() = space.begin(); + head = space.begin(); } - buf_write (o, pointer,n); + buf_write (pointer, n); } } diff --git a/vowpalwabbit/io_buf.h b/vowpalwabbit/io_buf.h index 94d4902da7c..87d2961f9d3 100644 --- a/vowpalwabbit/io_buf.h +++ b/vowpalwabbit/io_buf.h @@ -52,6 +52,10 @@ license as described in the file LICENSE. class io_buf { + // used to check-sum i/o files for corruption detection + bool _verify_hash; + uint32_t _hash; + public: v_array space; //space.begin = beginning of loaded values. space.end = end of read or written values from/to the buffer. v_array files; @@ -61,10 +65,6 @@ class io_buf v_array currentname; v_array finalname; - // used to check-sum i/o files for corruption detection - bool verify_hash; - uint32_t hash; - static const int READ = 1; static const int WRITE = 2; @@ -78,8 +78,22 @@ class io_buf current = 0; count = 0; head = space.begin(); - verify_hash = false; - hash = 0; + _verify_hash = false; + _hash = 0; + } + + void verify_hash(bool verify) { + _verify_hash = verify; + // reset the hash so that the io_buf can be re-used for loading + // as it is done for Reload() + if(!verify) + _hash = 0; + } + + uint32_t hash() { + if (!_verify_hash) + THROW("HASH WAS NOT CALCULATED"); + return _hash; } virtual int open_file(const char* name, bool stdin_off, int flag=READ) @@ -203,69 +217,69 @@ class io_buf } static bool is_socket(int f); -}; -void buf_write(io_buf &o, char* &pointer, size_t n); -size_t buf_read(io_buf &i, char* &pointer, size_t n); -bool isbinary(io_buf &i); -size_t readto(io_buf &i, char* &pointer, char terminal); + void buf_write(char* &pointer, size_t n); + size_t buf_read(char* &pointer, size_t n); + + //if read_message is null, just read it in. Otherwise do a comparison and barf on read_message. + size_t bin_read_fixed(char* data, size_t len, const char* read_message) + { if (len > 0) + { char* p; + // if the model is corrupt the number of bytes can be less then specified (as there isn't enought data available in the file) + len = buf_read(p,len); + + // compute hash for check-sum + if (_verify_hash) + _hash = (uint32_t)uniform_hash(p, len, _hash); + + if (*read_message == '\0') + memcpy(data,p,len); + else if (memcmp(data,p,len) != 0) + THROW(read_message); + return len; + } + return 0; + } + + size_t bin_write_fixed(const char* data, size_t len) + { if (len > 0) + { char* p; + buf_write (p, len); -//if read_message is null, just read it in. Otherwise do a comparison and barf on read_message. -inline size_t bin_read_fixed(io_buf& i, char* data, size_t len, const char* read_message) -{ if (len > 0) - { char* p; - // if the model is corrupt the number of bytes can be less then specified (as there isn't enought data available in the file) - len = buf_read(i,p,len); - - // compute hash for check-sum - if (i.verify_hash) - i.hash = (uint32_t)uniform_hash(p, len, i.hash); - - if (*read_message == '\0') - memcpy(data,p,len); - else if (memcmp(data,p,len) != 0) - THROW(read_message); + memcpy (p, data, len); + + // compute hash for check-sum + if (_verify_hash) + _hash = (uint32_t)uniform_hash(p, len, _hash); + } return len; } - return 0; -} +}; + +bool isbinary(io_buf &i); +size_t readto(io_buf &i, char* &pointer, char terminal); inline size_t bin_read(io_buf& i, char* data, size_t len, const char* read_message) { uint32_t obj_len; - size_t ret = bin_read_fixed(i,(char*)&obj_len,sizeof(obj_len),""); + size_t ret = i.bin_read_fixed((char*)&obj_len,sizeof(obj_len),""); if (obj_len > len || ret < sizeof(uint32_t)) THROW("bad model format!"); - ret += bin_read_fixed(i,data,obj_len,read_message); + ret += i.bin_read_fixed(data,obj_len,read_message); return ret; } -inline size_t bin_write_fixed(io_buf& o, const char* data, size_t len) -{ if (len > 0) - { char* p; - buf_write (o, p, len); - - memcpy (p, data, len); - - // compute hash for check-sum - if (o.verify_hash) - { o.hash = (uint32_t)uniform_hash(p, len, o.hash); - } - } - return len; -} - inline size_t bin_write(io_buf& o, const char* data, uint32_t len) -{ bin_write_fixed(o,(char*)&len, sizeof(len)); - bin_write_fixed(o,data,len); +{ o.bin_write_fixed((char*)&len, sizeof(len)); + o.bin_write_fixed(data,len); return (len + sizeof(len)); } inline size_t bin_text_write(io_buf& io, char* data, size_t len, std::stringstream& msg, bool text) { if (text) - { size_t temp = bin_write_fixed (io, msg.str().c_str(), msg.str().size()); + { size_t temp = io.bin_write_fixed (msg.str().c_str(), msg.str().size()); msg.str(""); return temp; } @@ -287,12 +301,12 @@ inline size_t bin_text_read_write(io_buf& io, char* data, size_t len, inline size_t bin_text_write_fixed(io_buf& io, char* data, size_t len, std::stringstream& msg, bool text) { if (text) - { size_t temp = bin_write_fixed(io, msg.str().c_str(), msg.str().size()); + { size_t temp = io.bin_write_fixed(msg.str().c_str(), msg.str().size()); msg.str(""); return temp; } else - return bin_write_fixed (io, data, len); + return io.bin_write_fixed (data, len); return 0; } @@ -301,7 +315,7 @@ inline size_t bin_text_read_write_fixed(io_buf& io, char* data, size_t len, const char* read_message, bool read, std::stringstream& msg, bool text) { if (read) - return bin_read_fixed(io, data, len, read_message); + return io.bin_read_fixed(data, len, read_message); else return bin_text_write_fixed(io, data, len, msg, text); } diff --git a/vowpalwabbit/kernel_svm.cc b/vowpalwabbit/kernel_svm.cc index 38ee429790a..2ad5f351d14 100644 --- a/vowpalwabbit/kernel_svm.cc +++ b/vowpalwabbit/kernel_svm.cc @@ -220,14 +220,14 @@ int save_load_flat_example(io_buf& model_file, bool read, flat_example*& fec) if(read) { fec = &calloc_or_throw(); - brw = bin_read_fixed(model_file, (char*) fec, sizeof(flat_example), ""); + brw = model_file.bin_read_fixed((char*) fec, sizeof(flat_example), ""); if(brw > 0) { if(fec->tag_len > 0) { fec->tag = calloc_or_throw(fec->tag_len); - brw = bin_read_fixed(model_file, (char*) fec->tag, fec->tag_len*sizeof(char), ""); + brw = model_file.bin_read_fixed((char*) fec->tag, fec->tag_len*sizeof(char), ""); if(!brw) return 2; } if(fec->fs.size() > 0) @@ -236,13 +236,13 @@ int save_load_flat_example(io_buf& model_file, bool read, flat_example*& fec) size_t len = fs.size(); fs.values = v_init(); fs.values.resize(len); - brw = bin_read_fixed(model_file, (char*) fs.values.begin(), len*sizeof(feature_value), ""); if(!brw) return 3; + brw = model_file.bin_read_fixed((char*) fs.values.begin(), len*sizeof(feature_value), ""); if(!brw) return 3; fs.values.end() = fs.values.begin()+len; len = fs.indicies.size(); fs.indicies = v_init(); fs.indicies.resize(len); - brw = bin_read_fixed(model_file, (char*) fs.indicies.begin(), len*sizeof(feature_index), ""); if(!brw) return 3; + brw = model_file.bin_read_fixed((char*) fs.indicies.begin(), len*sizeof(feature_index), ""); if(!brw) return 3; fs.indicies.end() = fs.indicies.begin()+len; } } @@ -250,13 +250,13 @@ int save_load_flat_example(io_buf& model_file, bool read, flat_example*& fec) } else { - brw = bin_write_fixed(model_file, (char*) fec, sizeof(flat_example)); + brw = model_file.bin_write_fixed((char*) fec, sizeof(flat_example)); if(brw > 0) { if(fec->tag_len > 0) { - brw = bin_write_fixed(model_file, (char*) fec->tag, (uint32_t)fec->tag_len*sizeof(char)); + brw = model_file.bin_write_fixed((char*) fec->tag, (uint32_t)fec->tag_len*sizeof(char)); if(!brw) { cerr<tag_len<<" "<tag<fs.size() > 0) { - brw = bin_write_fixed(model_file, (char*) fec->fs.values.begin(), (uint32_t)fec->fs.size()*sizeof(feature_value)); if(!brw) return 3; - brw = bin_write_fixed(model_file, (char*) fec->fs.indicies.begin(), (uint32_t)fec->fs.indicies.size()*sizeof(feature_index)); if(!brw) return 3; + brw = model_file.bin_write_fixed((char*) fec->fs.values.begin(), (uint32_t)fec->fs.size()*sizeof(feature_value)); if(!brw) return 3; + brw = model_file.bin_write_fixed((char*) fec->fs.indicies.begin(), (uint32_t)fec->fs.indicies.size()*sizeof(feature_index)); if(!brw) return 3; } } else return 1; @@ -880,9 +880,9 @@ LEARNER::base_learner* kernel_svm_setup(arguments& arg) // Need to update the loss_function argument in case a reduction tries to determine the function. auto it = find(arg.args.begin(), arg.args.end(), "--loss_function"); - if (it == arg.args.end()) - { - arg.args.push_back("--loss_function"); + if (it == arg.args.end()) + { + arg.args.push_back("--loss_function"); arg.args.push_back("hinge"); } else diff --git a/vowpalwabbit/lda_core.cc b/vowpalwabbit/lda_core.cc index 699bd4aaf1a..f4c61b034a5 100644 --- a/vowpalwabbit/lda_core.cc +++ b/vowpalwabbit/lda_core.cc @@ -85,7 +85,7 @@ struct lda // if it makes it into VS 2015 change the next ifdef to check Visual Studio Release // static constexpr float underflow_threshold = 1.0e-10f; - inline const float underflow_threshold() { return 1.0e-10f; } + inline float underflow_threshold() { return 1.0e-10f; } inline float digamma(float x); inline float lgamma(float x); @@ -207,9 +207,9 @@ template float v4sf_index(const v4sf x) // Specialization for the 0'th element template <> float v4sf_index<0>(const v4sf x) { return _mm_cvtss_f32(x); } -inline const v4sf v4sfl(const float x) { return _mm_set1_ps(x); } +inline v4sf v4sfl(const float x) { return _mm_set1_ps(x); } -inline const v4si v4sil(const uint32_t x) { return _mm_set1_epi32(x); } +inline v4si v4sil(const uint32_t x) { return _mm_set1_epi32(x); } #ifdef WIN32 @@ -397,25 +397,25 @@ void vexpdigammify_2(vw &all, float* gamma, const float *norm, const float under // The generic template is specialized for the particular accuracy setting. // Log gamma: -template inline T lgamma(T x) +template inline T lgamma(T /* x */) { BOOST_STATIC_ASSERT_MSG(true, "ldamath::lgamma is not defined for this type and math mode."); } // Digamma: -template inline T digamma(T x) +template inline T digamma(T /* x */) { BOOST_STATIC_ASSERT_MSG(true, "ldamath::digamma is not defined for this type and math mode."); } // Exponential -template inline T exponential(T x) +template inline T exponential(T /* x */) { BOOST_STATIC_ASSERT_MSG(true, "ldamath::exponential is not defined for this type and math mode."); } // Powf -template inline T powf(T x, T p) +template inline T powf(T /* x */, T /* p */) { BOOST_STATIC_ASSERT_MSG(true, "ldamath::powf is not defined for this type and math mode."); } diff --git a/vowpalwabbit/log_multi.cc b/vowpalwabbit/log_multi.cc index 047222cc06c..0e91d74e126 100644 --- a/vowpalwabbit/log_multi.cc +++ b/vowpalwabbit/log_multi.cc @@ -245,7 +245,7 @@ bool children(log_multi& b, uint32_t& current, uint32_t& class_index, uint32_t l return b.nodes[current].internal; } -void train_node(log_multi& b, single_learner& base, example& ec, uint32_t& current, uint32_t& class_index, uint32_t depth) +void train_node(log_multi& b, single_learner& base, example& ec, uint32_t& current, uint32_t& class_index, uint32_t /* depth */) { if(b.nodes[current].norm_Eh > b.nodes[current].preds[class_index].norm_Ehk) ec.l.simple.label = -1.f; diff --git a/vowpalwabbit/loss_functions.cc b/vowpalwabbit/loss_functions.cc index dae79ce3e02..ef8339b2bc5 100644 --- a/vowpalwabbit/loss_functions.cc +++ b/vowpalwabbit/loss_functions.cc @@ -98,7 +98,7 @@ class classic_squaredloss : public loss_function return example_loss; } - float getUpdate(float prediction, float label,float update_scale, float pred_per_update) + float getUpdate(float prediction, float label,float update_scale, float /* pred_per_update */) { return 2.f*(label - prediction) * update_scale; } @@ -362,7 +362,7 @@ class poisson_loss : public loss_function return (label - exp_prediction) * update_scale; } - float getRevertingWeight(shared_data* sd, float prediction, float eta_t) + float getRevertingWeight(shared_data* /* sd */, float /* prediction */, float /* eta_t */) { THROW("Active learning not supported by poisson loss"); } @@ -379,7 +379,7 @@ class poisson_loss : public loss_function return (exp_prediction - label); } - float second_derivative(shared_data*, float prediction, float label) + float second_derivative(shared_data*, float prediction, float /* label */) { float exp_prediction = expf(prediction); return exp_prediction; diff --git a/vowpalwabbit/multiclass.cc b/vowpalwabbit/multiclass.cc index ccad13890dc..fe9881bc29b 100644 --- a/vowpalwabbit/multiclass.cc +++ b/vowpalwabbit/multiclass.cc @@ -27,7 +27,7 @@ size_t read_cached_label(shared_data*, void* v, io_buf& cache) label_t* ld = (label_t*) v; char *c; size_t total = sizeof(ld->label)+sizeof(ld->weight); - if (buf_read(cache, c, total) < total) + if (cache.buf_read(c, total) < total) return 0; bufread_label(ld,c); @@ -53,7 +53,7 @@ void cache_label(void* v, io_buf& cache) { char *c; label_t* ld = (label_t*) v; - buf_write(cache, c, sizeof(ld->label)+sizeof(ld->weight)); + cache.buf_write(c, sizeof(ld->label)+sizeof(ld->weight)); bufcache_label(ld,c); } diff --git a/vowpalwabbit/multilabel.cc b/vowpalwabbit/multilabel.cc index 302cfbbfa79..a51b489f85d 100644 --- a/vowpalwabbit/multilabel.cc +++ b/vowpalwabbit/multilabel.cc @@ -12,7 +12,7 @@ char* bufread_label(labels* ld, char* c, io_buf& cache) ld->label_v.clear(); c += sizeof(size_t); size_t total = sizeof(uint32_t)*num; - if (buf_read(cache, c, (int)total) < total) + if (cache.buf_read(c, (int)total) < total) { cout << "error in demarshal of cost data" << endl; return c; @@ -33,7 +33,7 @@ size_t read_cached_label(shared_data*, void* v, io_buf& cache) ld->label_v.clear(); char *c; size_t total = sizeof(size_t); - if (buf_read(cache, c, (int)total) < total) + if (cache.buf_read(c, (int)total) < total) return 0; bufread_label(ld,c, cache); @@ -61,7 +61,7 @@ void cache_label(void* v, io_buf& cache) { char *c; labels* ld = (labels*) v; - buf_write(cache, c, sizeof(size_t)+sizeof(uint32_t)*ld->label_v.size()); + cache.buf_write(c, sizeof(size_t)+sizeof(uint32_t)*ld->label_v.size()); bufcache_label(ld,c); } diff --git a/vowpalwabbit/no_label.cc b/vowpalwabbit/no_label.cc index df3b967e2d0..11f7fc805c4 100644 --- a/vowpalwabbit/no_label.cc +++ b/vowpalwabbit/no_label.cc @@ -11,23 +11,23 @@ using namespace std; namespace no_label { - char* bufread_no_label(shared_data* sd, label_data* ld, char* c) { return c; } + char* bufread_no_label(shared_data*, label_data*, char* c) { return c; } - size_t read_cached_no_label(shared_data* sd, void* v, io_buf& cache) { return 1; } + size_t read_cached_no_label(shared_data*, void*, io_buf&) { return 1; } - float get_weight(void* v) { return 1.; } + float get_weight(void*) { return 1.; } - char* bufcache_no_label(label_data* ld, char* c) { return c; } + char* bufcache_no_label(label_data*, char* c) { return c; } - void cache_no_label(void* v, io_buf& cache) { } + void cache_no_label(void*, io_buf&) { } - void default_no_label(void* v) { } + void default_no_label(void*) { } - bool test_label(void* v) { return false; } + bool test_label(void*) { return false; } void delete_no_label(void*) {} - void parse_no_label(parser*, shared_data* sd, void* v, v_array& words) + void parse_no_label(parser*, shared_data*, void*, v_array& words) { switch(words.size()) { diff --git a/vowpalwabbit/parse_example_json.h b/vowpalwabbit/parse_example_json.h index a04b336e3fc..cf3a8e362f7 100644 --- a/vowpalwabbit/parse_example_json.h +++ b/vowpalwabbit/parse_example_json.h @@ -114,7 +114,7 @@ struct BaseState return nullptr; } - virtual BaseState* Key(Context& ctx, const char* str, rapidjson::SizeType len, bool copy) + virtual BaseState* Key(Context& ctx, const char* str, rapidjson::SizeType len, bool /* copy */) { ctx.error() << "Unexpected token: key('" << str << "' len: " << len << ")"; return nullptr; @@ -153,7 +153,7 @@ class LabelObjectState : public BaseState { } - void init(vw* all) + void init(vw* /* all */) { found = found_cb = false; @@ -177,7 +177,7 @@ class LabelObjectState : public BaseState return this; } - BaseState* Key(Context& ctx, const char* str, rapidjson::SizeType len, bool copy) + BaseState* Key(Context& ctx, const char* str, rapidjson::SizeType len, bool /* copy */) { ctx.key = str; ctx.key_length = len; @@ -314,7 +314,7 @@ struct LabelState : BaseState return ctx.label_object_state.StartObject(ctx); } - BaseState* String(Context& ctx, const char* str, rapidjson::SizeType len, bool copy) + BaseState* String(Context& ctx, const char* str, rapidjson::SizeType /* len */, bool copy) { // only to be used with copy=false assert(!copy); @@ -496,7 +496,7 @@ class ArrayState : public BaseState return Float(ctx, (float)f); } - BaseState* Null(Context& ctx) + BaseState* Null(Context& /* ctx */) { // ignore null values and stay in current state return this; @@ -510,7 +510,7 @@ class ArrayState : public BaseState return &ctx.default_state; } - BaseState* EndArray(Context& ctx, rapidjson::SizeType elementCount) + BaseState* EndArray(Context& ctx, rapidjson::SizeType /* elementCount */) { return ctx.PopNamespace(); } @@ -776,19 +776,19 @@ class ArrayToVectorState : public BaseState return this; } - BaseState* Uint(Context& ctx, unsigned f) + BaseState* Uint(Context& /* ctx */, unsigned f) { output_array->push_back((T)f); return this; } - BaseState* Float(Context& ctx, float f) + BaseState* Float(Context& /* ctx */, float f) { output_array->push_back((T)f); return this; } - BaseState* Null(Context& ctx) + BaseState* Null(Context& /* ctx */) { // ignore null values and stay in current state return this; @@ -810,7 +810,7 @@ class StringToStringState : public BaseState std::string* output_string; - BaseState* String(Context& ctx, const char* str, rapidjson::SizeType length, bool copy) + BaseState* String(Context& ctx, const char* str, rapidjson::SizeType length, bool /* copy */) { output_string->assign(str, str + length); @@ -897,19 +897,19 @@ class DecisionServiceState : public BaseState DecisionServiceInteraction* data; - BaseState* StartObject(Context& ctx) + BaseState* StartObject(Context& /* ctx */) { // TODO: improve validation return this; } - BaseState* EndObject(Context& ctx, rapidjson::SizeType memberCount) + BaseState* EndObject(Context& /* ctx */, rapidjson::SizeType /* memberCount */) { // TODO: improve validation return this; } - BaseState* Key(Context& ctx, const char* str, rapidjson::SizeType length, bool copy) + BaseState* Key(Context& ctx, const char* str, rapidjson::SizeType length, bool /* copy */) { if (length == 1) { @@ -1131,7 +1131,7 @@ struct VWReaderHandler : public rapidjson::BaseReaderHandler, bool VWReaderHandlerDefault() { return false; } // alternative to above if we want to re-use the VW float parser... - bool RawNumber(const char* str, rapidjson::SizeType length, bool copy) { return false; } + bool RawNumber(const char* /* str */, rapidjson::SizeType /* length */, bool /* copy */) { return false; } std::stringstream& error() { return ctx.error(); } diff --git a/vowpalwabbit/parse_regressor.cc b/vowpalwabbit/parse_regressor.cc index 6e96ce8582c..1f29d2ad2d0 100644 --- a/vowpalwabbit/parse_regressor.cc +++ b/vowpalwabbit/parse_regressor.cc @@ -28,7 +28,7 @@ using namespace std; template class set_initial_wrapper { public: - static void func(weight& w, float& initial, uint64_t index) { w = initial; } + static void func(weight& w, float& initial, uint64_t /* index */) { w = initial; } }; template class random_positive_wrapper @@ -76,10 +76,10 @@ template void truncate(vw& all,T& weights) }); } -template double calculate_sd(vw& all,T& weights) +template double calculate_sd(vw& /* all */,T& weights) { static int my_size = 0; - for_each(weights.begin(), weights.end(), [](float v) {my_size += 1;}); + for_each(weights.begin(), weights.end(), [](float /* v */) {my_size += 1;}); double sum = accumulate(weights.begin(), weights.end(), 0.0); double mean = sum / my_size; vector diff(my_size); @@ -200,7 +200,7 @@ void save_load_header(vw& all, io_buf& model_file, bool read, bool text) VW::validate_version(all); if (all.model_file_ver >= VERSION_FILE_WITH_HEADER_CHAINED_HASH) - model_file.verify_hash = true; + model_file.verify_hash(true); if (all.model_file_ver >= VERSION_FILE_WITH_HEADER_ID) { @@ -456,11 +456,11 @@ void save_load_header(vw& all, io_buf& model_file, bool read, bool text) if (read) { uint32_t len; - size_t ret = bin_read_fixed(model_file, (char*)&len, sizeof(len), ""); + size_t ret = model_file.bin_read_fixed((char*)&len, sizeof(len), ""); if (len > 104857600 /*sanity check: 100 Mb*/ || ret < sizeof(uint32_t)) THROW("bad model format!"); resize_buf_if_needed(buff2, buf2_size, len); - bytes_read_write += bin_read_fixed(model_file, buff2, len, "") + ret; + bytes_read_write += model_file.bin_read_fixed(buff2, len, "") + ret; all.opts_n_args.file_options->str(buff2); } else @@ -483,7 +483,7 @@ void save_load_header(vw& all, io_buf& model_file, bool read, bool text) if (all.model_file_ver >= VERSION_FILE_WITH_HEADER_HASH) { uint32_t check_sum = (all.model_file_ver >= VERSION_FILE_WITH_HEADER_CHAINED_HASH) ? - model_file.hash : + model_file.hash() : (uint32_t)uniform_hash(model_file.space.begin(), bytes_read_write, 0); uint32_t check_sum_saved = check_sum; @@ -498,11 +498,7 @@ void save_load_header(vw& all, io_buf& model_file, bool read, bool text) if (all.model_file_ver >= VERSION_FILE_WITH_HEADER_CHAINED_HASH) { - model_file.verify_hash = false; - - // reset the hash so that the io_buf can be re-used for loading - // as it is done for Reload() - model_file.hash = 0; + model_file.verify_hash(false); } } } diff --git a/vowpalwabbit/parser.cc b/vowpalwabbit/parser.cc index a3cbd01a654..95bac70c886 100644 --- a/vowpalwabbit/parser.cc +++ b/vowpalwabbit/parser.cc @@ -484,6 +484,7 @@ void enable_sources(vw& all, bool quiet, size_t passes) // background process (if foreground is not set) if (!all.opts_n_args.vm.count("foreground")) { + //FIXME switch to posix_spawn if (!all.active && daemon(1,1)) THROWERRNO("daemon"); } @@ -969,7 +970,7 @@ void parse_example_label(vw& all, example&ec, string label) words.delete_v(); } -void empty_example(vw& all, example& ec) +void empty_example(vw& /* all */, example& ec) { for (features& fs : ec) fs.clear(); diff --git a/vowpalwabbit/parser_helper.h b/vowpalwabbit/parser_helper.h index 2e156afa37b..c9beb59f062 100644 --- a/vowpalwabbit/parser_helper.h +++ b/vowpalwabbit/parser_helper.h @@ -80,7 +80,7 @@ class arguments { { return operator()(option, po::value(&store)->default_value(def) - ->notifier([this, option, def] (T arg) + ->notifier([this, option] (T arg) { *this->file_options << " --" << long_only(option) << " " << arg; }), diff --git a/vowpalwabbit/print.cc b/vowpalwabbit/print.cc index b20e24a4eee..0c6fc062aa0 100644 --- a/vowpalwabbit/print.cc +++ b/vowpalwabbit/print.cc @@ -5,7 +5,7 @@ using namespace std; struct print { vw* all; }; //regressor, feature loop -void print_feature(vw& all, float value, uint64_t index) +void print_feature(vw& /* all */, float value, uint64_t index) { cout << index; if (value != 1.) diff --git a/vowpalwabbit/recall_tree.cc b/vowpalwabbit/recall_tree.cc index d871d32f347..a035516cb6c 100644 --- a/vowpalwabbit/recall_tree.cc +++ b/vowpalwabbit/recall_tree.cc @@ -250,7 +250,7 @@ void add_node_id_feature (recall_tree& b, uint32_t cn, example& ec) // TODO: if namespace already exists ? } -void remove_node_id_feature (recall_tree& b, uint32_t cn, example& ec) +void remove_node_id_feature (recall_tree& /* b */, uint32_t /* cn */, example& ec) { features& fs = ec.feature_space[node_id_namespace]; fs.clear(); diff --git a/vowpalwabbit/search.cc b/vowpalwabbit/search.cc index 6234cb22f78..43a92aba9f8 100644 --- a/vowpalwabbit/search.cc +++ b/vowpalwabbit/search.cc @@ -501,7 +501,7 @@ void add_new_feature(search_private& priv, float val, uint64_t idx) } } -void del_features_in_top_namespace(search_private& priv, example& ec, size_t ns) +void del_features_in_top_namespace(search_private& /* priv */, example& ec, size_t ns) { if ((ec.indices.size() == 0) || (ec.indices.last() != ns)) { @@ -1440,7 +1440,7 @@ void foreach_action_from_cache(search_private& priv, size_t t, action override_a } // note: ec_cnt should be 1 if we are not LDF -action search_predict(search_private& priv, example* ecs, size_t ec_cnt, ptag mytag, const action* oracle_actions, size_t oracle_actions_cnt, const ptag* condition_on, const char* condition_on_names, const action* allowed_actions, size_t allowed_actions_cnt, const float* allowed_actions_cost, size_t learner_id, float& a_cost, float weight) +action search_predict(search_private& priv, example* ecs, size_t ec_cnt, ptag mytag, const action* oracle_actions, size_t oracle_actions_cnt, const ptag* condition_on, const char* condition_on_names, const action* allowed_actions, size_t allowed_actions_cnt, const float* allowed_actions_cost, size_t learner_id, float& a_cost, float /* weight */) { size_t condition_on_cnt = condition_on_names ? strlen(condition_on_names) : 0; size_t t = priv.t + priv.meta_t; diff --git a/vowpalwabbit/search_dep_parser.cc b/vowpalwabbit/search_dep_parser.cc index 95e9c04735f..3dd1d5fb8ca 100644 --- a/vowpalwabbit/search_dep_parser.cc +++ b/vowpalwabbit/search_dep_parser.cc @@ -110,12 +110,12 @@ void finish(Search::search& sch) delete data; } -void inline add_feature(example& ex, uint64_t idx, unsigned char ns, uint64_t mask, uint64_t multiplier, bool audit=false) +void inline add_feature(example& ex, uint64_t idx, unsigned char ns, uint64_t mask, uint64_t multiplier, bool /* audit */=false) { ex.feature_space[(int)ns].push_back(1.0f, (idx * multiplier) & mask); } -void add_all_features(example& ex, example& src, unsigned char tgt_ns, uint64_t mask, uint64_t multiplier, uint64_t offset, bool audit=false) +void add_all_features(example& ex, example& src, unsigned char tgt_ns, uint64_t mask, uint64_t multiplier, uint64_t offset, bool /* audit */=false) { features& tgt_fs = ex.feature_space[tgt_ns]; for (namespace_index ns : src.indices) @@ -133,7 +133,7 @@ void inline reset_ex(example *ex) } // arc-hybrid System. -size_t transition_hybrid(Search::search& sch, uint64_t a_id, uint32_t idx, uint32_t t_id, uint32_t n) +size_t transition_hybrid(Search::search& sch, uint64_t a_id, uint32_t idx, uint32_t t_id, uint32_t /* n */) { task_data *data = sch.get_task_data(); v_array &heads=data->heads, &stack=data->stack, &gold_heads=data->gold_heads, &gold_tags=data->gold_tags, &tags = data->tags; @@ -461,7 +461,7 @@ void get_cost_to_go_losses(Search::search &sch, v_array>& go } } -void get_gold_actions(Search::search &sch, uint32_t idx, uint64_t n, v_array& gold_actions) +void get_gold_actions(Search::search &sch, uint32_t idx, uint64_t /* n */, v_array& gold_actions) { task_data *data = sch.get_task_data(); v_array &action_loss = data->action_loss, &stack = data->stack, &gold_heads=data->gold_heads, &valid_actions=data->valid_actions; diff --git a/vowpalwabbit/search_entityrelationtask.cc b/vowpalwabbit/search_entityrelationtask.cc index b2e0d244784..13ac42a8525 100644 --- a/vowpalwabbit/search_entityrelationtask.cc +++ b/vowpalwabbit/search_entityrelationtask.cc @@ -400,7 +400,7 @@ void run(Search::search& sch, multi_ex& ec) predictions.delete_v(); } // this is totally bogus for the example -- you'd never actually do this! -void update_example_indicies(bool audit, example* ec, uint64_t mult_amount, uint64_t plus_amount) +void update_example_indicies(bool /* audit */, example* ec, uint64_t mult_amount, uint64_t plus_amount) { for (features& fs : *ec) for (feature_index& idx : fs.indicies) diff --git a/vowpalwabbit/search_sequencetask.cc b/vowpalwabbit/search_sequencetask.cc index 362ad5222bd..069547ee91c 100644 --- a/vowpalwabbit/search_sequencetask.cc +++ b/vowpalwabbit/search_sequencetask.cc @@ -238,7 +238,7 @@ void run(Search::search& sch, multi_ex& ec) namespace SequenceTaskCostToGo { -void initialize(Search::search& sch, size_t& num_actions, arguments& arg) +void initialize(Search::search& sch, size_t& num_actions, arguments& /* arg */) { sch.set_options( Search::AUTO_CONDITION_FEATURES | // automatically add history features to our examples, please Search::AUTO_HAMMING_LOSS | // please just use hamming loss on individual predictions -- we won't declare loss @@ -379,7 +379,7 @@ void finish(Search::search& sch) // this is totally bogus for the example -- you'd never actually do this! -void my_update_example_indicies(Search::search& sch, bool audit, example* ec, uint64_t mult_amount, uint64_t plus_amount) +void my_update_example_indicies(Search::search& sch, bool /* audit */, example* ec, uint64_t mult_amount, uint64_t plus_amount) { size_t ss = sch.get_stride_shift(); for (features& fs : *ec) diff --git a/vowpalwabbit/simple_label.cc b/vowpalwabbit/simple_label.cc index 39c17668fc9..5b28cbcfb21 100644 --- a/vowpalwabbit/simple_label.cc +++ b/vowpalwabbit/simple_label.cc @@ -28,7 +28,7 @@ size_t read_cached_simple_label(shared_data* sd, void* v, io_buf& cache) label_data* ld = (label_data*) v; char *c; size_t total = sizeof(ld->label)+sizeof(ld->weight)+sizeof(ld->initial); - if (buf_read(cache, c, total) < total) + if (cache.buf_read(c, total) < total) return 0; bufread_simple_label(sd, ld,c); @@ -56,7 +56,7 @@ void cache_simple_label(void* v, io_buf& cache) { char *c; label_data* ld = (label_data*) v; - buf_write(cache, c, sizeof(ld->label)+sizeof(ld->weight)+sizeof(ld->initial)); + cache.buf_write(c, sizeof(ld->label)+sizeof(ld->weight)+sizeof(ld->initial)); bufcache_simple_label(ld,c); }