From 22f0b4dd0b81bce75ac7a842a72ca86eec02f7bc Mon Sep 17 00:00:00 2001 From: Mika Laitio Date: Mon, 23 Jul 2012 18:20:53 +0300 Subject: [PATCH] cleanups Signed-off-by: Mika Laitio --- src/Factory.cc | 18 +++++++++--------- src/Factory.hh | 8 ++++---- src/W1Device.cc | 5 ++++- src_test/test_w1_datalog_write.cc | 6 +++--- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/Factory.cc b/src/Factory.cc index 9d704b5..bcd43ec 100644 --- a/src/Factory.cc +++ b/src/Factory.cc @@ -78,7 +78,7 @@ string Factory::get_device_type_by_family_code(int family_code_param) { return ret_val; } -Device *Factory::create_w1_device(int family_code_param, +Device *Factory::create_device(int family_code_param, string device_id_param, dirent *direntry_param) { Device *ret_val; @@ -87,7 +87,7 @@ Device *Factory::create_w1_device(int family_code_param, ret_val = NULL; type = get_device_type_by_family_code(family_code_param); if (type.empty() == false) { - ret_val = create_w1_device(family_code_param, + ret_val = create_device(family_code_param, type, device_id_param, direntry_param); @@ -95,7 +95,7 @@ Device *Factory::create_w1_device(int family_code_param, return ret_val; } -Device *Factory::create_w1_device(int device_w1_family_code_param, +Device *Factory::create_device(int device_w1_family_code_param, string device_type_param, string device_id_param, dirent *direntry_param) { @@ -137,7 +137,7 @@ Device *Factory::create_w1_device(int device_w1_family_code_param, return ret_val; } -Device *Factory::create_w1_device(string device_type_param, +Device *Factory::create_device(string device_type_param, string device_id_param) { int family_code; Device *ret_val; @@ -146,13 +146,13 @@ Device *Factory::create_w1_device(string device_type_param, if (device_type_param.empty() == false) { family_code = get_family_code_by_device_type(device_type_param); if (family_code != -1) { - ret_val = create_w1_device(family_code, device_type_param, device_id_param, NULL); + ret_val = create_device(family_code, device_type_param, device_id_param, NULL); } } return ret_val; } -Device *Factory::create_w1_device(dirent *direntry_param, +Device *Factory::create_device(dirent *direntry_param, int *err_code_param) { string folder_name; string tmp_str; @@ -175,7 +175,7 @@ Device *Factory::create_w1_device(dirent *direntry_param, if (suc_flg == true) { log_debug("1-wire device family code: %#x\n", family_code); device_id = folder_name.substr(pos + 1, folder_name.length() - pos); - ret_val = Factory::create_w1_device(family_code, + ret_val = Factory::create_device(family_code, device_id, direntry_param); if ((ret_val == NULL) && @@ -213,7 +213,7 @@ list Factory::get_device_list() { is_subdir = FileUtil::is_subdirectory(W1_SCAN_ROOTDIR, direntry); if (is_subdir == true) { err_flg = 0; - device = create_w1_device(direntry, &err_flg); + device = create_device(direntry, &err_flg); if (device != NULL) { ret_val.push_back(device); } @@ -248,7 +248,7 @@ list Factory::get_device_list() { // reader device is not in the list of active devices. create and add it to list as in-active one... type = reader->get_device_type(); if (type.empty() == false) { - device = create_w1_device(type, id1); + device = create_device(type, id1); if (device != NULL) { ret_val.push_back(device); } diff --git a/src/Factory.hh b/src/Factory.hh index a4c1c1f..5eccf31 100644 --- a/src/Factory.hh +++ b/src/Factory.hh @@ -29,10 +29,10 @@ namespace w1 { static std::list get_device_list(); private: //int parse_family_code(string folder_name); - static plp::Device *create_w1_device(int family_code_param, string device_type_param, string device_id_param, dirent *direntry_param); - static plp::Device *create_w1_device(int family_code, string device_id, dirent *direntry_param); - static plp::Device *create_w1_device(string device_type_param, string device_id_param); - static plp::Device *create_w1_device(dirent *direntry_param, int *err_code_param); + static plp::Device *create_device(int family_code_param, string device_type_param, string device_id_param, dirent *direntry_param); + static plp::Device *create_device(int family_code, string device_id, dirent *direntry_param); + static plp::Device *create_device(string device_type_param, string device_id_param); + static plp::Device *create_device(dirent *direntry_param, int *err_code_param); static std::list get_data_reader_list(); static int get_family_code_by_device_type(string device_type_param); static string get_device_type_by_family_code(int family_code_param); diff --git a/src/W1Device.cc b/src/W1Device.cc index 576d216..0ee5898 100644 --- a/src/W1Device.cc +++ b/src/W1Device.cc @@ -155,7 +155,10 @@ void W1Device::save_and_clean_cache() { dec_precision = get_data_decimal_precision(); pthread_mutex_lock(&plock); - log_debug("memory cache size: %lu\n", memory_cache.size()); + /* needs to be casted to long unsigned int value is "unsigned int" in some + toolchains and that would otherwise cause an warning/error + */ + log_debug("memory cache size: %lu\n", (long unsigned int)memory_cache.size()); StoreDay::save(id, &memory_cache, dec_precision); while(memory_cache.empty() == false) { data = memory_cache.back(); diff --git a/src_test/test_w1_datalog_write.cc b/src_test/test_w1_datalog_write.cc index 748b9fe..a0c0cc2 100644 --- a/src_test/test_w1_datalog_write.cc +++ b/src_test/test_w1_datalog_write.cc @@ -49,12 +49,12 @@ bool try_parse_long(const char *str, long *result) { } int main(int argc, char** argv) { - list device_list; int read_count_total; long cnt_max_scans; long read_interval_seconds; string loc; Device *device; + list device_list; list::iterator iter; // default values than can be overwritten with parameters @@ -101,7 +101,7 @@ int main(int argc, char** argv) { log_info("closing the application, max read count reached. (%ld)\n", cnt_max_scans); break; } - for(iter = device_list.begin(); iter != device_list.end(); iter++) { + for (iter = device_list.begin(); iter != device_list.end(); iter++) { device = (Device *)*iter; if (device->get_lifecycle_state() == LIFECYCLE_STATUS__AVAILABLE) { device->printout(); @@ -115,7 +115,7 @@ int main(int argc, char** argv) { } } else { - log_debug("could not find 1-wire devices.\n"); + log_debug("could not find devices.\n"); } log_debug("trying to start emptying list\n"); while (device_list.empty() == false) { -- 2.41.1