First off, I assume that the patch is created as a text file (GPSPatch.diff) in my case, then applied to the source code using a command like: patch -uNp1 -i GPSPatch.diff
then I recompile using (sudo)
./configure
make
make install
If that's not how to patch a program that's already compiled, if someone can put me on the right path, I'd appreciate it greatly.
Assuming I'm right so far:
When I invoke: patch -uNp1 --dry-run --verbose -i GPSPatch.diff
I get errors. The first seems to just be related to indentation (****malformed patch at [lines not indented])
So, after I fix the indentation, that error goes away, and if I run the command again, I get this:
patch: **** malformed patch at line 11: long aggregate_points;
which I think I can fix with changing (line numbers added by me):
Code:
4 @@ -183,7 +183,7 @@
TO:
Code:
4 @@ -183,9 +183,9 @@
Original code here (line numbers added by me):
Code:
4 @@ -183,7 +183,7 @@ 5 double min_lat, min_lon, min_alt, min_spd; 6 double max_lat, max_lon, max_alt, max_spd; 7 // Aggregate/avg center position 8 - long unsigned int add_lat, add_lon, add_alt; 9 + uint64_t add_lat, add_lon, add_alt; 10 double aggregate_lat, aggregate_lon, aggregate_alt; 11 long aggregate_points; 12 }; 13 diff -Naur orig/util.cc new/util.cc 14 --- orig/util.cc 2013-03-27 15:41:48.000000000 +0100 15 +++ new/util.cc 2014-05-25 12:54:54.000000000 +0200 16 @@ -1093,11 +1093,11 @@
I am surprised that the patch writer didn't see this though: Is my correction right?
SO, once I get the first two errors to go away, I get this:
**** malformed patch at line 13: diff -Naur orig/util.cc new/util.cc
which refers to this line:
diff -Naur orig/util.cc new/util.cc
Is this because I need to break this patch up into individual files before applying them?
It seems like it, but I'd like to know if there's an easier way. From what little I know about Linux, it always seems like there's an easier way... Thanks as always to anyone who offers assistance!
Kevin
The Link:
https://www.kismetwireless.net/Forum...1016156.530417
The patch contained in the link:
This patch fixes the problem by using a bigger integer type. Verified on a raspberry pi but the problem should be present on all plattforms where 32-bit integers actually are 32-bit. The comments regarding number range is not corrected.
Code:
diff -Naur orig/gpscore.h new/gpscore.h --- orig/gpscore.h 2013-03-27 15:41:48.000000000 +0100 +++ new/gpscore.h 2014-05-25 12:55:15.000000000 +0200 @@ -183,7 +183,7 @@ double min_lat, min_lon, min_alt, min_spd; double max_lat, max_lon, max_alt, max_spd; // Aggregate/avg center position - long unsigned int add_lat, add_lon, add_alt; + uint64_t add_lat, add_lon, add_alt; double aggregate_lat, aggregate_lon, aggregate_alt; long aggregate_points; }; diff -Naur orig/util.cc new/util.cc --- orig/util.cc 2013-03-27 15:41:48.000000000 +0100 +++ new/util.cc 2014-05-25 12:54:54.000000000 +0200 @@ -1093,11 +1093,11 @@ /* Airware PPI gps conversion code from Johnny Csh */ /* - * input: a unsigned 32-bit (native endian) value between 0 and 3600000000 (inclusive) + * input: a unsigned 64-bit (native endian) value between 0 and 3600000000 (inclusive) * output: a signed floating point value betwen -180.0000000 and + 180.0000000, inclusive) */ -double fixed3_7_to_double(u_int32_t in) { - int32_t remapped_in = in - (180 * 10000000); +double fixed3_7_to_double(u_int64_t in) { + int64_t remapped_in = in - (180 * 10000000); double ret = (double) ((double) remapped_in / 10000000); return ret; } @@ -1105,16 +1105,16 @@ * input: a native 32 bit unsigned value between 0 and 999999999 * output: a positive floating point value between 000.0000000 and 999.9999999 */ -double fixed3_6_to_double(u_int32_t in) { +double fixed3_6_to_double(u_int64_t in) { double ret = (double) in / 1000000.0; return ret; } /* - * input: a native 32 bit unsigned value between 0 and 999.999999 + * input: a native 64 bit unsigned value between 0 and 999.999999 * output: a signed floating point value between -180000.0000 and +180000.0000 */ -double fixed6_4_to_double(u_int32_t in) { - int32_t remapped_in = in - (180000 * 10000); +double fixed6_4_to_double(u_int64_t in) { + int64_t remapped_in = in - (180000 * 10000); double ret = (double) ((double) remapped_in / 10000); return ret; } @@ -1130,38 +1130,38 @@ /* * input: a signed floating point value betwen -180.0000000 and + 180.0000000, inclusive) - * output: a unsigned 32-bit (native endian) value between 0 and 3600000000 (inclusive) + * output: a unsigned 64-bit (native endian) value between 0 and 3600000000 (inclusive) */ -u_int32_t double_to_fixed3_7(double in) +u_int64_t double_to_fixed3_7(double in) { - if (in < -180 || in >= 180) + if (in < -180 || in >= 180) return 0; //This may be positive or negative. - int32_t scaled_in = (int32_t) ((in) * (double) 10000000); + int64_t scaled_in = (int64_t) ((in) * (double) 10000000); //If the input conditions are met, this will now always be positive. - u_int32_t ret = (u_int32_t) (scaled_in + ((int32_t) 180 * 10000000)); + u_int64_t ret = (u_int64_t) (scaled_in + ((int64_t) 180 * 10000000)); return ret; } /* * input: a signed floating point value betwen -180000.0000 and + 180000.0000, inclusive) - * output: a unsigned 32-bit (native endian) value between 0 and 3600000000 (inclusive) + * output: a unsigned 64-bit (native endian) value between 0 and 3600000000 (inclusive) */ -u_int32_t double_to_fixed6_4(double in) +u_int64_t double_to_fixed6_4(double in) { - if (in < -180000.0001 || in >= 180000.0001) + if (in < -180000.0001 || in >= 180000.0001) return 0; //This may be positive or negative. - int32_t scaled_in = (int32_t) ((in) * (double) 10000); + int64_t scaled_in = (int64_t) ((in) * (double) 10000); //If the input conditions are met, this will now always be positive. - u_int32_t ret = (u_int32_t) (scaled_in + ((int32_t) 180000 * 10000)); + u_int64_t ret = (u_int64_t) (scaled_in + ((int64_t) 180000 * 10000)); return ret; } /* * input: a positive floating point value between 000.0000000 and 999.9999999 * output: a native 32 bit unsigned value between 0 and 999999999 */ -u_int32_t double_to_fixed3_6(double in) { - u_int32_t ret = (u_int32_t) (in * (double) 1000000.0); +u_int64_t double_to_fixed3_6(double in) { + u_int64_t ret = (u_int64_t) (in * (double) 1000000.0); return ret; } diff -Naur orig/util.h new/util.h --- orig/util.h 2013-03-27 15:41:48.000000000 +0100 +++ new/util.h 2014-05-25 12:54:54.000000000 +0200 @@ -236,13 +236,13 @@ * the fixedX_Y fixed point values into 'native' doubles for displaying. * Documentation on these formats can be found in the PPI-GEOLOCATION specification */ -double fixed3_7_to_double(u_int32_t in); -double fixed3_6_to_double(u_int32_t in); -double fixed6_4_to_double(u_int32_t in); +double fixed3_7_to_double(u_int64_t in); +double fixed3_6_to_double(u_int64_t in); +double fixed6_4_to_double(u_int64_t in); -u_int32_t double_to_fixed3_7(double in); -u_int32_t double_to_fixed3_6(double in); -u_int32_t double_to_fixed6_4(double in); +u_int64_t double_to_fixed3_7(double in); +u_int64_t double_to_fixed3_6(double in); +u_int64_t double_to_fixed6_4(double in); /* * Some values are encoded as 32-bit unsigned nano-second counters.