-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4541 from YosysHQ/krys/compiler-warnings
Resolve (some) compiler warnings
- Loading branch information
Showing
8 changed files
with
80 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- System.cc | ||
+++ System.cc | ||
@@ -43,7 +43,7 @@ static inline int memReadStat(int field) | ||
pid_t pid = getpid(); | ||
int value; | ||
|
||
- sprintf(name, "/proc/%d/statm", pid); | ||
+ snprintf(name, 256, "/proc/%d/statm", pid); | ||
FILE* in = fopen(name, "rb"); | ||
if (in == NULL) return 0; | ||
|
||
@@ -60,7 +60,7 @@ static inline int memReadPeak(void) | ||
char name[256]; | ||
pid_t pid = getpid(); | ||
|
||
- sprintf(name, "/proc/%d/status", pid); | ||
+ snprintf(name, 256, "/proc/%d/status", pid); | ||
FILE* in = fopen(name, "rb"); | ||
if (in == NULL) return 0; | ||
|
||
--- Vec.h | ||
+++ Vec.h | ||
@@ -100,7 +100,13 @@ void vec<T,_Size>::capacity(Size min_cap) { | ||
Size add = max((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2 | ||
const Size size_max = std::numeric_limits<Size>::max(); | ||
if ( ((size_max <= std::numeric_limits<int>::max()) && (add > size_max - cap)) | ||
- || (((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM) ) | ||
+ || ( | ||
+#ifdef _DEFAULT_SOURCE | ||
+ ((data = (T*)::reallocarray(data, (cap += add), sizeof(T))) == NULL) | ||
+#else | ||
+ ((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) | ||
+#endif | ||
+ && errno == ENOMEM) ) | ||
throw OutOfMemoryException(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters