Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List API add const and return object on *_del #4723

Merged
merged 4 commits into from
Aug 1, 2019

Conversation

sworleys
Copy link
Member

Add const where appropriate to the new list APIs.

We were not implementing the *_del() API according to our docs here: http://docs.frrouting.org/projects/dev-guide/en/latest/lists.html#c.Z_del

This patch implements *_del appropriately for all but the atomic list API. For that, it will return the object that was passed, but no NULL return is done if its not found in the list. This will remain a TODO for someone who has a better understanding of the atomic code path.

@polychaeta polychaeta added libfrr tests Topotests, make check, etc labels Jul 23, 2019
@LabN-CI
Copy link
Collaborator

LabN-CI commented Jul 23, 2019

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/4723 7ee2140
Date 07/23/2019
Start 17:50:22
Finish 18:12:01
Run-Time 21:39
Total 1815
Pass 1815
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2019-07-23-17:50:22.txt
Log autoscript-2019-07-23-17:51:10.log.bz2
Memory 402 423 360

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-8430/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

Warnings Generated during build:

Checkout code: Successful with additional warnings
Report for typerb.h | 8 issues
===============================================
< WARNING: function definition argument 'const struct typed_rb_root *' should also have an identifier name
< #48: FILE: /tmp/f1-30195/typerb.h:48:
< WARNING: function definition argument 'const struct typed_rb_root *' should also have an identifier name
< #53: FILE: /tmp/f1-30195/typerb.h:53:
< WARNING: function definition argument 'const struct typed_rb_root *' should also have an identifier name
< #58: FILE: /tmp/f1-30195/typerb.h:58:
< WARNING: function definition argument 'const struct typed_rb_root *' should also have an identifier name
< #63: FILE: /tmp/f1-30195/typerb.h:63:
Report for typesafe.h | 4 issues
===============================================
< ERROR: code indent should use tabs where possible
< #123: FILE: /tmp/f1-30195/typesafe.h:123:
< WARNING: please, no spaces at the start of a line
< #123: FILE: /tmp/f1-30195/typesafe.h:123:

Warnings Generated during build:

Debian 10 amd64 build: Successful with additional warnings

Debian Package lintian failed for Debian 10 amd64 build:
(see full package build log at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-8430/artifact/DEB10BUILD/ErrorLog/log_lintian.txt)

W: frr source: changelog-should-mention-nmu

CLANG Static Analyzer Summary

  • Github Pull Request 4723, comparing to Git base SHA c5cdc2b

No Changes in Static Analysis warnings compared to base

1 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-8430/artifact/shared/static_analysis/index.html

@LabN-CI
Copy link
Collaborator

LabN-CI commented Jul 24, 2019

🚧 Basic BGPD CI results: Partial FAILURE, 1 tests failed

Results table
_ _
Result SUCCESS git merge/4723 f761d31
Date 07/24/2019
Start 11:42:25
Finish 12:03:58
Run-Time 21:33
Total 1815
Pass 1814
Fail 1
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2019-07-24-11:42:25.txt
Log autoscript-2019-07-24-11:43:16.log.bz2
Memory 434 419 360

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-8435/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

Warnings Generated during build:

Debian 10 amd64 build: Successful with additional warnings

Debian Package lintian failed for Debian 10 amd64 build:
(see full package build log at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-8435/artifact/DEB10BUILD/ErrorLog/log_lintian.txt)

W: frr source: changelog-should-mention-nmu

CLANG Static Analyzer Summary

  • Github Pull Request 4723, comparing to Git base SHA 6879c08

No Changes in Static Analysis warnings compared to base

1 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-8435/artifact/shared/static_analysis/index.html

Copy link
Contributor

@mjstapp mjstapp left a comment

Choose a reason for hiding this comment

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

This looks good to me - should wait for David L to get a chance to review it also. Is the CI failure real or spurious?

@sworleys
Copy link
Member Author

This looks good to me - should wait for David L to get a chance to review it also. Is the CI failure real or spurious?

I imagine its spurious but I don't have access to look at it...

@LabN-CI
Copy link
Collaborator

LabN-CI commented Jul 26, 2019

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/4723 f761d31
Date 07/25/2019
Start 21:24:00
Finish 21:45:33
Run-Time 21:33
Total 1815
Pass 1815
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2019-07-25-21:24:00.txt
Log autoscript-2019-07-25-21:24:49.log.bz2
Memory 433 425 360

For details, please contact louberger

Copy link
Contributor

@eqvinox eqvinox left a comment

Choose a reason for hiding this comment

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

Can't go from const trees to non-const items.

lib/typerb.c Outdated
int (*cmpfn)(
const struct typed_rb_entry *a,
const struct typed_rb_entry *b))
struct rb_entry *typed_rb_find(const struct rbt_tree *rbt,
Copy link
Contributor

Choose a reason for hiding this comment

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

NAK on returning a non-const rb_entry from a const rbt_tree

As much as I like putting const on things, this is a situation where it doesn't really work out.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, can you elaborate a bit more on why this is an issue? Is actually a code issue or just an API nit because I can't produce a test case where it is breaking stuff.

Also, is it just a problem with the _find() api or do _first() and others need to be changed back as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem is that const on the data structure head doesn't have clearly defined semantics.

  • does it mean that I'm not supposed to allocate/free the head? That doesn't work because the DS might need to change something in the head on insertion, so cross that out...
  • does it mean that I'm not supposed to change the DS but can do with the items what I want? That's kinda weird... why is the DS const but not the items?
  • does it mean that I'm not supposed to change anything? Then the items need to be const too...

Even if we agree on a semantic to attach, I'd argue that this is non-obvious enough to make sticking const on the DS head useless.

(My comment applies to all functions, _first & co too.)

So — what's your use case?

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't think this was a problem when I saw it - though I think I understand your question. The use-case for const collection but not const item would be that I want to modify an item in a collection, but not the collection itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, yea that makes sense. Thanks for taking the time to explain that.

I mostly decided whether my const decisions were appropriate by looking at the linux implementation: https://github.com/torvalds/linux/blob/master/include/linux/rbtree.h

But I definitely agree it in non-obvious, so I will remove it.

I will need to remove it in the other API's in typesafe.h as well,

Copy link
Member

Choose a reason for hiding this comment

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

@eqvinox and @sworleys -> does any of this conversation need to be recorded in doc/developer somewhere?

sworleys added 4 commits July 31, 2019 11:35
The new list api did not implement the `*_del` endpoint as
it was described in the docs here:

http://docs.frrouting.org/projects/dev-guide/en/latest/lists.html#c.Z_del

This patch implements the endpoints to return the object deleted if
found, otherwise NULL for all but the atomic lists.

The atomic list `*_del` code is marked as TODO and will remain undefined
for now.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Add some asserts where `list_del()` is called to verify they object
was found when it was deleted.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Checkpatch was complaining about the lack of identifiers here, so
added some.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Add const to the datastructure being passed to the new list APIs
for the `_count()` calls.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
@sworleys
Copy link
Member Author

Force-pushed to rebase and remove const on the data structures for everything but the _count() api calls.

@LabN-CI
Copy link
Collaborator

LabN-CI commented Jul 31, 2019

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/4723 0ca16c5
Date 07/31/2019
Start 12:00:35
Finish 12:22:20
Run-Time 21:45
Total 1815
Pass 1815
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2019-07-31-12:00:35.txt
Log autoscript-2019-07-31-12:01:26.log.bz2
Memory 432 435 361

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-8486/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

Warnings Generated during build:

Debian 10 amd64 build: Successful with additional warnings

Debian Package lintian failed for Debian 10 amd64 build:
(see full package build log at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-8486/artifact/DEB10BUILD/ErrorLog/log_lintian.txt)

W: frr source: changelog-should-mention-nmu

CLANG Static Analyzer Summary

  • Github Pull Request 4723, comparing to Git base SHA 2e6f2d6

No Changes in Static Analysis warnings compared to base

1 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-8486/artifact/shared/static_analysis/index.html

@eqvinox eqvinox merged commit 2e2094b into FRRouting:master Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libfrr tests Topotests, make check, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants