Skip to content

allow terabytes, tebibytes, petabytes,pebibytes, exabytes and exbibytes modifiers when specifying sizes#600

Merged
pstorz merged 6 commits intomasterfrom
dev/pstorz/master/terabyte-sizes
Sep 18, 2020
Merged

allow terabytes, tebibytes, petabytes,pebibytes, exabytes and exbibytes modifiers when specifying sizes#600
pstorz merged 6 commits intomasterfrom
dev/pstorz/master/terabyte-sizes

Conversation

@pstorz
Copy link
Member

@pstorz pstorz commented Sep 16, 2020

The configuratoin parser now additionally allows the following modifiers:

t 1,099,511,627,776 (tebibytes)

tb 1,000,000,000,000 (terabytes)

p 1,125,899,906,842,624 (pebibytes)

pb 1,000,000,000,000,000 (petabytes)

e 1,152,921,504,606,846,976 (exbibytes)

eb 1,000,000,000,000,000,000 (exabytes)

Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have just some minor remarks. The whole edit.cc would probably benefit a lot if it was redesigned completely.

1};

if (value == 0) {
result += "0";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we just return "0" here?


std::string PrintNumberSiPrefixFormat(ResourceItem* item, uint64_t value_in)
{
PoolMem temp;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function will probably yield an unused parameter warning on compile.
You could just use ResourceItem* (without a parameter name) to identify the value as unused.
Probably it is even better to remove this function completely and replace with SizeAsSiPrefixFormat() where applicable.

{
char str[] = "1 k";
uint64_t retvalue = 0;
size_to_uint64(str, &retvalue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing size_to_uint64(char*, uint64_t*) into size_to_uint64(const char*, uint64_t*) should be rather trivial and would allow to pass constant strings.

@arogge
Copy link
Member

arogge commented Sep 16, 2020

I just looked at the code, but didn't test it.

Co-authored-by: Andreas Rogge <andreas.rogge@bareos.com>
@pstorz pstorz merged commit 8aac631 into master Sep 18, 2020
@pstorz pstorz deleted the dev/pstorz/master/terabyte-sizes branch September 18, 2020 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants