Skip to content

sys: ringbuffer: rb_add_elements() don't overwrite existing content#933

Closed
Kijewski wants to merge 3 commits intoRIOT-OS:masterfrom
Kijewski:issue-933
Closed

sys: ringbuffer: rb_add_elements() don't overwrite existing content#933
Kijewski wants to merge 3 commits intoRIOT-OS:masterfrom
Kijewski:issue-933

Conversation

@Kijewski
Copy link
Copy Markdown
Contributor

rb_add_elements() is undocumented and currently unused. I'd like to use it. My problem is that the function overwrites existing content. Hence it doesn't return how many elements were added.
The corresponding get function rb_get_elements() only reads as many elements as there are stored, and returns the number of actually read elements.

Are there objections to change the behavior of rb_add_elements() not to overwrite existing elements?

@Kijewski
Copy link
Copy Markdown
Contributor Author

Added commits.

This was referenced Mar 28, 2014
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you change this to the worse, @file FILENAME.[c|h] is the preferred style here...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The name is filled in automatically. Declaring the name makes finding the source of the definition more difficult in the generated HTML.

@haukepetersen
Copy link
Copy Markdown
Contributor

+1 for the changes!

Just seems to me the implementation is not yet complete?!

@Kijewski
Copy link
Copy Markdown
Contributor Author

It is complete. I only changed rb_add_elements() and documented the existing functions.
If the implementation does not fit the documentation, then the comments need to be fixed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Align with other comments.

@kaspar030
Copy link
Copy Markdown
Contributor

Also +1 for the changes!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe, while you're at it: rename ringbuffer_add_element

@kaspar030
Copy link
Copy Markdown
Contributor

@authmillenon really, ringbuffer_*? Why write out everything? I prefer the short names.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Apr 14, 2014

Because rb_* could refer to anything and thus can lead to problems in readability (and portability).

@Kijewski
Copy link
Copy Markdown
Contributor Author

I like longer names, too. Even my smallish editor Geany supports autocompletion, and every major editor (vim, emacs, Eclipse, …) does, too.

@kaspar030
Copy link
Copy Markdown
Contributor

Do we like longer names because our editor supports autocompletion?

I like shorter names because they IMHO increase readability. Guess you would state the opposite?

@kaspar030
Copy link
Copy Markdown
Contributor

I'm even for renaming rb_add_elements to rb_add and get rid of the single byte version altogether for external use (or change it to rb_addone).

@miri64
Copy link
Copy Markdown
Member

miri64 commented Apr 14, 2014

It's more a "where does this come from" readability, than a "This code line is shorter then 50 chars" readability I meant.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Apr 14, 2014

If we call the module rb I would not have any problems with rb_ ;-) But I do not think this would be usefull.

@kaspar030
Copy link
Copy Markdown
Contributor

why not call the module ringbuffer so it's clear what it contains. Call the type ringbuffer_t because it is only used in definitions and signature. Call the functions rb_* so we don't have to type our fingers wound. As soon as we have anything prone to collide with rb_*, we can rediscuss our convention here.

ringbuffer_init could be renamed, though...

@kaspar030
Copy link
Copy Markdown
Contributor

Let's prefer practical inconsistency over academic consistency.

@Kijewski
Copy link
Copy Markdown
Contributor Author

Let's prefer practical inconsistency over academic consistency.

Imgur

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

*from

@OlegHahm
Copy link
Copy Markdown
Member

#define rb_ ringbuffer_

? ;-)

@miri64
Copy link
Copy Markdown
Member

miri64 commented Apr 15, 2014

Can you rebase please? :D I'd like to use this PR for my packet buffer but am not able to write unittests.

@Kijewski Kijewski changed the title sys: rb_add_elements() don't overwrite existing content sys: ringbuffer: rb_add_elements() don't overwrite existing content Apr 15, 2014
@Kijewski
Copy link
Copy Markdown
Contributor Author

@authmillenon, rebased.

@Kijewski
Copy link
Copy Markdown
Contributor Author

Kijewski commented May 3, 2014

This PR was superseded by #1101.

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented May 4, 2014

Close?

@Kijewski
Copy link
Copy Markdown
Contributor Author

Kijewski commented May 4, 2014

I wanted to wait if someone has some final comment, or if there is a strong opposition against the other PR. Right now there is not much comment on #1101. : )

@Kijewski
Copy link
Copy Markdown
Contributor Author

Kijewski commented May 8, 2014

Replaced by #1101. I'm closing this PR as I won't rebase this branch.

@Kijewski Kijewski closed this May 8, 2014
@Kijewski Kijewski deleted the issue-933 branch May 8, 2014 16:17
@Kijewski Kijewski modified the milestone: Release 2014.05 May 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants