]> git.zerfleddert.de Git - hmcfgusb/blobdiff - firmware.c
Suppress warnings about non-literal format strings
[hmcfgusb] / firmware.c
index bd13dbe2fb3bbf3b0085347b5ac5003967445260..6a544a33bb35db42d330b7f313fb21700d669fbc 100644 (file)
@@ -1,6 +1,6 @@
 /* generic firmware-functions for HomeMatic
  *
 /* generic firmware-functions for HomeMatic
  *
- * Copyright (c) 2014 Michael Gernoth <michael@gernoth.net>
+ * Copyright (c) 2014-16 Michael Gernoth <michael@gernoth.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
 #include <fcntl.h>
 #include <sys/time.h>
 
 #include <fcntl.h>
 #include <sys/time.h>
 
+#include "util.h"
 #include "firmware.h"
 
 /* This might be wrong, but it works for current fw */
 #include "firmware.h"
 
 /* This might be wrong, but it works for current fw */
-#define MAX_BLOCK_LENGTH       512
-
-static uint8_t ascii_to_nibble(uint8_t a)
-{
-       uint8_t c = 0x00;
-
-       if ((a >= '0') && (a <= '9')) {
-               c = a - '0';
-       } else if ((a >= 'A') && (a <= 'F')) {
-               c = (a - 'A') + 10;
-       } else if ((a >= 'a') && (a <= 'f')) {
-               c = (a - 'a') + 10;
-       }
-
-       return c;
-}
-
-static int validate_nibble(uint8_t a)
-{
-       if (((a >= '0') && (a <= '9')) ||
-           ((a >= 'A') && (a <= 'F')) ||
-           ((a >= 'a') && (a <= 'f')))
-               return 1;
-
-       return 0;
-}
+#define MAX_BLOCK_LENGTH       2048
 
 struct firmware* firmware_read_firmware(char *filename, int debug)
 {
 
 struct firmware* firmware_read_firmware(char *filename, int debug)
 {
@@ -119,7 +95,6 @@ struct firmware* firmware_read_firmware(char *filename, int debug)
                len |= (ascii_to_nibble(buf[2]) & 0xf)<< 4;
                len |= ascii_to_nibble(buf[3]) & 0xf;
 
                len |= (ascii_to_nibble(buf[2]) & 0xf)<< 4;
                len |= ascii_to_nibble(buf[3]) & 0xf;
 
-               /* This might be wrong, but it works for current fw->fw */
                if (len > MAX_BLOCK_LENGTH) {
                        fprintf(stderr, "Invalid block-length %u > %u for block %d!\n", len, MAX_BLOCK_LENGTH, fw->fw_blocks+1);
                        exit(EXIT_FAILURE);
                if (len > MAX_BLOCK_LENGTH) {
                        fprintf(stderr, "Invalid block-length %u > %u for block %d!\n", len, MAX_BLOCK_LENGTH, fw->fw_blocks+1);
                        exit(EXIT_FAILURE);
Impressum, Datenschutz