diff options
author | INAGAKI Hiroshi <musashino.open@gmail.com> | 2020-10-31 21:45:05 +0900 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2020-11-12 18:19:44 +0100 |
commit | 65f3e7ce1f4ad0abda9f0b98ffb7972960602b41 (patch) | |
tree | 84f652d0208271eec5dc2bf72af503803f8fade6 | |
parent | 165f0b00cdd2f763c1d478c2f58c535fc19b13bd (diff) | |
download | upstream-65f3e7ce1f4ad0abda9f0b98ffb7972960602b41.tar.gz upstream-65f3e7ce1f4ad0abda9f0b98ffb7972960602b41.tar.bz2 upstream-65f3e7ce1f4ad0abda9f0b98ffb7972960602b41.zip |
firmware-utils: fix mistake and improve logic in nec-enc
this patch fixes/improves follows:
- PATTERN_LEN is defined as a macro but unused
- redundant logic in count-up for "ptn"
Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
-rw-r--r-- | tools/firmware-utils/Makefile | 2 | ||||
-rw-r--r-- | tools/firmware-utils/src/nec-enc.c | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile index 7f1754a347..81c62d977a 100644 --- a/tools/firmware-utils/Makefile +++ b/tools/firmware-utils/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME := firmware-utils -PKG_RELEASE := 4 +PKG_RELEASE := 5 include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/kernel.mk diff --git a/tools/firmware-utils/src/nec-enc.c b/tools/firmware-utils/src/nec-enc.c index 3c4e38721e..a2be378586 100644 --- a/tools/firmware-utils/src/nec-enc.c +++ b/tools/firmware-utils/src/nec-enc.c @@ -47,7 +47,7 @@ static unsigned char buf_pattern[4096], buf[4096]; int main(int argc, char **argv) { - int k_off = 0, ptn = 0, c, ret = EXIT_SUCCESS; + int k_off = 0, ptn = 1, c, ret = EXIT_SUCCESS; char *ifn = NULL, *ofn = NULL, *key = NULL; size_t n, k_len; FILE *out, *in; @@ -99,11 +99,11 @@ int main(int argc, char **argv) while ((n = fread(buf, 1, sizeof(buf), in)) > 0) { for (int i = 0; i < n; i++) { - buf_pattern[i] = ptn + 1; + buf_pattern[i] = ptn; ptn++; - if (ptn > 250) - ptn = 0; + if (ptn > PATTERN_LEN) + ptn = 1; } k_off = xor_pattern(buf_pattern, n, key, k_len, k_off); |