mirror of
https://github.com/adafruit/Adafruit_GPS.git
synced 2026-10-26 22:10:17 +00:00
Attempt to fix compiler warnings
This commit is contained in:
1 parent
4005211fd4
commit
2a3cf8264d
3 files changed
+19
-3
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
name=Adafruit GPS Library
|
||||
version=1.7.4
|
||||
version=1.7.5
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=An interrupt-based GPS library for no-parsing-required use
|
||||
|
||||
@@ -351,7 +351,8 @@ char Adafruit_GPS::read(void) {
|
||||
}
|
||||
// Serial.print(c);
|
||||
|
||||
currentline[lineidx++] = c;
|
||||
currentline[lineidx] = c;
|
||||
lineidx++;
|
||||
if (lineidx >= MAXLINELENGTH)
|
||||
lineidx = MAXLINELENGTH -
|
||||
1; // ensure there is someplace to put the next received character
|
||||
|
||||
+16
-1
@@ -590,5 +590,20 @@ void Adafruit_GPS::addChecksum(char *buff) {
|
||||
cs ^= buff[i];
|
||||
i++;
|
||||
}
|
||||
sprintf(buff, "%s*%02X", buff, cs);
|
||||
|
||||
// Calculate the needed buffer size: original length + 3 (*XX) + 1 (null terminator)
|
||||
int neededSize = strlen(buff) + 4;
|
||||
char *tempBuffer = (char *)malloc(neededSize);
|
||||
|
||||
if (tempBuffer != NULL) {
|
||||
// Use snprintf to safely format the string with the checksum
|
||||
snprintf(tempBuffer, neededSize, "%s*%02X", buff, cs);
|
||||
|
||||
// Copy the formatted string back to the original buffer
|
||||
// Note: Make sure the original buffer is large enough to hold the new string.
|
||||
strcpy(buff, tempBuffer);
|
||||
|
||||
// Free the allocated memory to avoid memory leaks
|
||||
free(tempBuffer);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user