The Wayback Machine - https://web.archive.org/web/20230220184807/https://github.com/apache/trafficserver/issues/7108
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

Comment for ats_base64_ functions seems wrong #7108

Closed
maskit opened this issue Aug 12, 2020 · 8 comments · Fixed by #8835
Closed

Comment for ats_base64_ functions seems wrong #7108

maskit opened this issue Aug 12, 2020 · 8 comments · Fixed by #8835

Comments

@maskit
Copy link
Member

maskit commented Aug 12, 2020

The comment says functions return pointers for malloc-ed buffers, but the implementations don't seem like so.

* These routines return char*'s to malloc-ed strings. The caller is
* responsible for freeing the strings.

@yozaam
Copy link

yozaam commented Aug 21, 2020

  • These routines convert char*'s to malloc-ed strings. The caller is
  • responsible for freeing the strings.

Would that becorrect?

@maskit
Copy link
Member Author

maskit commented Aug 24, 2020

I think the routines do not allocate memory.

@alokrahul513
Copy link

Hi, I want to work on this issue. How to get started?

@Sid672
Copy link

Sid672 commented Sep 15, 2021

@maskit can you tell me what changes you want?
Removal of comments or modify them?

@maskit
Copy link
Member Author

maskit commented Sep 15, 2021

If you think the behavior is obvious and the comment is unnecessary, remove it.
If you think documentation is necessary, modify the comment so that it describes the behavior.

I think documentation is always nice to have, but it should not tell a lie if it exists. I'd modify the comment.

Here is the implementations if you need to know what the functions do.
https://github.com/apache/trafficserver/blob/master/src/tscore/ink_base64.cc

@Sid672
Copy link

Sid672 commented Sep 16, 2021

@maskit please correct me if I am wrong.
Functions:

1) bool ats_base64_encode(const char *inBuffer, size_t inBufferSize, char *outBuffer, size_t outBufSize, size_t *length);

2) bool ats_base64_encode(const unsigned char *inBuffer, size_t inBufferSize, char *outBuffer, size_t outBufSize, size_t *length);

3) bool ats_base64_decode(const char *inBuffer, size_t inBufferSize, unsigned char *outBuffer, size_t outBufSize, size_t *length);
  • The first function call the 2nd function.
  • 2nd function converts the character into binary up to the length of Buffersize and returns true if it is completed.
  • 3rd function decode the buffer and returns true after completion.

So can I add these comments:

* These routines convert char's of string and return true. 
@bryancall
Copy link
Contributor

@willwendorfvm Do you want to take a look at this?

@bryancall
Copy link
Contributor

@moonchen is going to take a look at this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment