The strtoull() man page suggests resetting errno and using that to
check for a parsing error. This ensures the OSD::load_pgs() callers are
getting what they expect (now that they aren't relying on the broken
behavior). The other callers in the os/* code is moved to a different
method that ignores the suffix.
Signed-off-by: Sage Weil <sage@inktank.com>
const char *snap_start = strchr(cstr, '_');
if (!snap_start)
return false;
- if (strncmp(snap_start, "_head", 5) == 0)
+ if (strncmp(snap_start, "_head", 5) == 0) {
snap = CEPH_NOSNAP;
- else
+ } else {
+ errno = 0;
snap = strtoull(snap_start+1, 0, 16);
+ if (errno)
+ return false;
+ }
return true;
}