#define MAX_ENTRIES 1000
size_t max_entries = op.max_entries;
- if (!max_entries || max_entries > MAX_ENTRIES)
+ if (max_entries > MAX_ENTRIES)
max_entries = MAX_ENTRIES;
string match_prefix;
do {
RGWUserBuckets buckets;
uint64_t read_count;
- if (limit > 0)
- read_count = min(limit - total_count, (uint64_t)max_buckets);
- else
- read_count = max_buckets;
+ read_count = min(limit - total_count, (uint64_t)max_buckets);
ret = rgw_read_user_buckets(store, s->user.user_id, buckets,
marker, read_count, should_get_stats());
total_count += m.size();
- done = (m.size() < read_count || (limit > 0 && total_count == limit));
+ done = (m.size() < read_count || total_count >= limit);
if (!m.empty()) {
send_response_data(buckets);
int RGWListBuckets_ObjStore_SWIFT::get_params()
{
marker = s->info.args.get("marker");
- string limit_str;
- limit_str = s->info.args.get("limit");
- long l = strtol(limit_str.c_str(), NULL, 10);
- if (l > (long)limit_max || l < 0)
- return -ERR_PRECONDITION_FAILED;
- limit = (uint64_t)l;
+ string limit_str = s->info.args.get("limit");
+ if (!limit_str.empty()) {
+ string err;
+ long l = strict_strtol(limit_str.c_str(), 10, &err);
+ if (!err.empty()) {
+ return -EINVAL;
+ }
+
+ if (l > (long)limit_max || l < 0) {
+ return -EINVAL;
+ }
- if (limit == 0)
- limit = limit_max;
+ limit = (uint64_t)l;
+ }
need_stats = (s->format != RGW_FORMAT_PLAIN);
bool stats, exists;
int r = s->info.args.get_bool("stats", &stats, &exists);
- if (r < 0)
+ if (r < 0) {
return r;
+ }
if (exists) {
need_stats = stats;