diff mbox series

[2/4] include/linux/ascii85: Update ascii85_encode()

Message ID 1542713851-14375-2-git-send-email-smasetty@codeaurora.org (mailing list archive)
State New, archived
Headers show
Series [1/4] drm/msm: use kvmalloc for ring data in gpu crashstate | expand

Commit Message

Sharat Masetty Nov. 20, 2018, 11:37 a.m. UTC
The current implementation of ascii85_encode() does not copy the encoded
buffer 'z' to the output buffer in case the input is zero. This patch
simply adds this missing piece. This makes it easier to use this
function to encode large buffers.

Signed-off-by: Sharat Masetty <smasetty@codeaurora.org>
---
 include/linux/ascii85.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Jordan Crouse Nov. 20, 2018, 3:47 p.m. UTC | #1
On Tue, Nov 20, 2018 at 05:07:29PM +0530, Sharat Masetty wrote:
> The current implementation of ascii85_encode() does not copy the encoded
> buffer 'z' to the output buffer in case the input is zero. This patch
> simply adds this missing piece. This makes it easier to use this
> function to encode large buffers.
> 
> Signed-off-by: Sharat Masetty <smasetty@codeaurora.org>

Adding intel-gfx since they are the other consumers of this code but this seems
legit to me.

Jordan

> ---
>  include/linux/ascii85.h | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/ascii85.h b/include/linux/ascii85.h
> index 4cc4020..00646fc 100644
> --- a/include/linux/ascii85.h
> +++ b/include/linux/ascii85.h
> @@ -23,8 +23,12 @@
>  {
>  	int i;
>  
> -	if (in == 0)
> -		return "z";
> +	if (in == 0) {
> +		out[0] = 'z';
> +		out[1] = '\0';
> +
> +		return out;
> +	}
>  
>  	out[5] = '\0';
>  	for (i = 5; i--; ) {
> -- 
> 1.9.1
>
diff mbox series

Patch

diff --git a/include/linux/ascii85.h b/include/linux/ascii85.h
index 4cc4020..00646fc 100644
--- a/include/linux/ascii85.h
+++ b/include/linux/ascii85.h
@@ -23,8 +23,12 @@ 
 {
 	int i;
 
-	if (in == 0)
-		return "z";
+	if (in == 0) {
+		out[0] = 'z';
+		out[1] = '\0';
+
+		return out;
+	}
 
 	out[5] = '\0';
 	for (i = 5; i--; ) {