diff --git a/src/public/libcmd/src/myCmd.cpp b/src/public/libcmd/src/myCmd.cpp index 83788bb..bd9d17e 100644 --- a/src/public/libcmd/src/myCmd.cpp +++ b/src/public/libcmd/src/myCmd.cpp @@ -140,15 +140,14 @@ void cmd_sub_complete(const char *buf, char ***completions, int *ncomp, { const char *prefix = strrchr(buf, ' '); - if (!prefix) + if (prefix) { - *ncomp = 0; - *completions = NULL; - - return; + prefix++; + } + else + { + prefix = buf; } - - prefix++; int cnt = 0; char **c = NULL; diff --git a/src/public/libfunc/src/myFunc.c b/src/public/libfunc/src/myFunc.c index 52fe113..1bd5ef5 100644 --- a/src/public/libfunc/src/myFunc.c +++ b/src/public/libfunc/src/myFunc.c @@ -107,12 +107,13 @@ uint16_t func_cal_sum_word(const uint8_t *d, uint32_t n) uint16_t func_cal_crc16(const uint8_t *d, uint32_t n) { - if (!d || !n) + if (!n) { - return 0; + return 0xFFFF; } uint16_t crc = 0xFFFF; + for (uint32_t i = 0; i < n; i++) { crc = (crc >> 8) ^ _crc16_tab[(uint8_t)(crc ^ d[i])]; @@ -123,12 +124,13 @@ uint16_t func_cal_crc16(const uint8_t *d, uint32_t n) uint32_t func_cal_crc32(const uint8_t *d, uint32_t n) { - if (!d || !n) + if (!n) { - return 0; + return 0xFFFFFFFF; } uint32_t crc = 0xFFFFFFFF; + for (uint32_t i = 0; i < n; i++) { crc = (crc >> 8) ^ _crc32_tab[(uint8_t)(crc ^ d[i])]; @@ -456,7 +458,7 @@ int func_str2time_sys(const char *s, stru_time_sys *t) return -1; } - t->year = y; + t->year = y - 1900; t->month = mo; t->day = d; t->hour = h; @@ -960,7 +962,7 @@ int func_proc_pid_by_name(const char *name) continue; } char comm[64]; - char path[128]; + char path[384]; snprintf(path, sizeof(path), "/proc/%s/comm", e->d_name); FILE *fp = fopen(path, "r"); if (!fp) diff --git a/src/public/libtask/src/myTask.c b/src/public/libtask/src/myTask.c index a42f4bf..ed3ee72 100644 --- a/src/public/libtask/src/myTask.c +++ b/src/public/libtask/src/myTask.c @@ -740,9 +740,10 @@ int task_msg_queue_recv(stru_task_msg_queue_t p_queue, void *msg, p->head = (p->head + 1) % p->max_msgs; p->msg_count--; + pthread_cond_signal(&p->cond); pthread_mutex_unlock(&p->lock); - return 0; + return (int)msg_len; } /** diff --git a/src/public/libxml/src/myXml.cpp b/src/public/libxml/src/myXml.cpp index a5cc4e3..aa501c4 100644 --- a/src/public/libxml/src/myXml.cpp +++ b/src/public/libxml/src/myXml.cpp @@ -131,8 +131,16 @@ myXmlElem_t myXml_new_child(myXmlElem_t parent, const char *name) } tinyxml2::XMLDocument *doc = ((tinyxml2::XMLElement *)parent)->GetDocument(); + tinyxml2::XMLElement *el = doc->NewElement(name); - return (myXmlElem_t)(doc->NewElement(name)); + if (!el) + { + return NULL; + } + + ((tinyxml2::XMLElement *)parent)->InsertEndChild(el); + + return (myXmlElem_t)(el); } void myXml_set_attr(myXmlElem_t elem, const char *name, const char *value)