| 741 | } |
| 742 | |
| 743 | int getUnsignedLongLongFromObject(robj *o, uint64_t *target) { |
| 744 | uint64_t value; |
| 745 | |
| 746 | if (o == NULL) { |
| 747 | value = 0; |
| 748 | } else { |
| 749 | serverAssertWithInfo(NULL,o,o->type == OBJ_STRING); |
| 750 | if (sdsEncodedObject(o)) { |
| 751 | char *pchEnd = nullptr; |
| 752 | errno = 0; |
| 753 | value = strtoull(szFromObj(o), &pchEnd, 10); |
| 754 | if (value == 0) { |
| 755 | // potential error |
| 756 | if (errno != 0) |
| 757 | return C_ERR; |
| 758 | if (pchEnd == szFromObj(o)) |
| 759 | return C_ERR; |
| 760 | } |
| 761 | } else if (o->encoding == OBJ_ENCODING_INT) { |
| 762 | value = (long)ptrFromObj(o); |
| 763 | } else { |
| 764 | serverPanic("Unknown string encoding"); |
| 765 | } |
| 766 | } |
| 767 | if (target) *target = value; |
| 768 | return C_OK; |
| 769 | } |
| 770 | |
| 771 | int getLongLongFromObjectOrReply(client *c, robj *o, long long *target, const char *msg) { |
| 772 | long long value; |
no test coverage detected