]> pilppa.com Git - lib1wire.git/commitdiff
cleanups
authorMika Laitio <lamikr@pilppa.org>
Mon, 23 Jul 2012 15:20:53 +0000 (18:20 +0300)
committerMika Laitio <lamikr@pilppa.org>
Mon, 23 Jul 2012 15:20:53 +0000 (18:20 +0300)
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
src/Factory.cc
src/Factory.hh
src/W1Device.cc
src_test/test_w1_datalog_write.cc

index 9d704b59e32b620489bd1174df32458a68e1c375..bcd43ec09478daf1c9408894d12b2e515b5574f1 100644 (file)
@@ -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<Device *> 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<Device *> 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);
                                }
index a4c1c1f4683e10415a711a9e36f0aaeae3dd2088..5eccf31f12adb5ce63bc4e3d2d2ccb806212ff6e 100644 (file)
@@ -29,10 +29,10 @@ namespace w1 {
                        static std::list<plp::Device *> 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<plp::DataReader *> 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);
index 576d216713e9e5f9223fa753c729d8f5aa1c77ed..0ee589845d75ba9ae0ecdddb142cded40c3beebf 100644 (file)
@@ -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();
index 748b9fe29ea2eb14f4b65e648405dd432a5b16a3..a0c0cc238ba707cc8400e4784da957130bd47f80 100644 (file)
@@ -49,12 +49,12 @@ bool try_parse_long(const char *str, long *result) {
 }
 
 int main(int argc, char** argv) {
-       list<Device *>                  device_list;
        int                             read_count_total;
        long                            cnt_max_scans;
        long                            read_interval_seconds;
        string                          loc;
        Device                          *device;
+       list<Device *>                  device_list;
        list<Device *>::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) {