| 612 | } |
| 613 | |
| 614 | int getDoubleFromObject(const robj *o, double *target) { |
| 615 | double value; |
| 616 | |
| 617 | if (o == NULL) { |
| 618 | value = 0; |
| 619 | } else { |
| 620 | serverAssertWithInfo(NULL,o,o->type == OBJ_STRING); |
| 621 | if (sdsEncodedObject(o)) { |
| 622 | if (!string2d(o->ptr, sdslen(o->ptr), &value)) |
| 623 | return C_ERR; |
| 624 | } else if (o->encoding == OBJ_ENCODING_INT) { |
| 625 | value = (long)o->ptr; |
| 626 | } else { |
| 627 | serverPanic("Unknown string encoding"); |
| 628 | } |
| 629 | } |
| 630 | *target = value; |
| 631 | return C_OK; |
| 632 | } |
| 633 | |
| 634 | int getDoubleFromObjectOrReply(client *c, robj *o, double *target, const char *msg) { |
| 635 | double value; |
no test coverage detected