[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #41500] SMTP base64 patch
From: |
Sergio R. Caprile |
Subject: |
[lwip-devel] [bug #41500] SMTP base64 patch |
Date: |
Thu, 26 Jun 2014 15:56:25 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:30.0) Gecko/20100101 Firefox/30.0 |
Follow-up Comment #1, bug #41500 (project lwip):
I would go for a more elegant way (also attached as a patch file):
```
--- a/apps/smtp/smtp.c
+++ b/apps/smtp/smtp.c
@@ -808,9 +808,9 @@ smtp_base64_encode(char* target, size_t target_len, const
ch
size_t i;
s8_t j;
size_t target_idx = 0;
- size_t longer = 3 - (source_len % 3);
+ size_t longer = (source_len % 3) ? (3 - (source_len % 3)) : 0;
size_t source_len_b64 = source_len + longer;
- size_t len = (((source_len_b64) * 4) / 3);
+ size_t len = (source_len_b64 / 3) * 4;
u8_t x = 5;
u8_t current = 0;
LWIP_UNUSED_ARG(target_len);
```
I guess we can assume the compiler will be smart enough to not do the modulus
calculation twice, and/or to do it as a simple &3.
(file #31623)
_______________________________________________________
Additional Item Attachment:
File name: smtp2.patch Size:0 KB
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?41500>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-devel] [bug #41500] SMTP base64 patch,
Sergio R. Caprile <=