| 654 | } |
| 655 | |
| 656 | int getDoubleFromObject(const robj *o, double *target) { |
| 657 | double value; |
| 658 | |
| 659 | if (o == NULL) { |
| 660 | value = 0; |
| 661 | } else { |
| 662 | serverAssertWithInfo(NULL,o,o->type == OBJ_STRING); |
| 663 | if (sdsEncodedObject(o)) { |
| 664 | if (!string2d(szFromObj(o), sdslen(szFromObj(o)), &value)) |
| 665 | return C_ERR; |
| 666 | } else if (o->encoding == OBJ_ENCODING_INT) { |
| 667 | value = (long)ptrFromObj(o); |
| 668 | } else { |
| 669 | serverPanic("Unknown string encoding"); |
| 670 | } |
| 671 | } |
| 672 | *target = value; |
| 673 | return C_OK; |
| 674 | } |
| 675 | |
| 676 | int getDoubleFromObjectOrReply(client *c, robj *o, double *target, const char *msg) { |
| 677 | double value; |
no test coverage detected