Fossil SCM
Changes to the file_getcwd() routine to avoid a false-positive compiler warning from gcc 10.2.1.
Commit
85b83206f42cb64b5699a721c67e12821d4502782ac57fa8f1bfd09cd78ce551
Parent
d7a2bda91238bdc…
1 file changed
+3
-4
+3
-4
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -1192,14 +1192,13 @@ | ||
| 1192 | 1192 | ** |
| 1193 | 1193 | ** Store the value of the CWD in zBuf which is nBuf bytes in size. |
| 1194 | 1194 | ** or if zBuf==0, allocate space to hold the result using fossil_malloc(). |
| 1195 | 1195 | */ |
| 1196 | 1196 | char *file_getcwd(char *zBuf, int nBuf){ |
| 1197 | - char zTemp[2000]; | |
| 1198 | 1197 | if( zBuf==0 ){ |
| 1199 | - zBuf = zTemp; | |
| 1200 | - nBuf = sizeof(zTemp); | |
| 1198 | + char zTemp[2000]; | |
| 1199 | + return fossil_strdup(file_getcwd(zTemp, sizeof(zTemp))); | |
| 1201 | 1200 | } |
| 1202 | 1201 | #ifdef _WIN32 |
| 1203 | 1202 | win32_getcwd(zBuf, nBuf); |
| 1204 | 1203 | #else |
| 1205 | 1204 | if( getcwd(zBuf, nBuf-1)==0 ){ |
| @@ -1209,11 +1208,11 @@ | ||
| 1209 | 1208 | fossil_fatal("cannot find current working directory; %s", |
| 1210 | 1209 | strerror(errno)); |
| 1211 | 1210 | } |
| 1212 | 1211 | } |
| 1213 | 1212 | #endif |
| 1214 | - return zBuf==zTemp ? fossil_strdup(zBuf) : zBuf; | |
| 1213 | + return zBuf; | |
| 1215 | 1214 | } |
| 1216 | 1215 | |
| 1217 | 1216 | /* |
| 1218 | 1217 | ** Return true if zPath is an absolute pathname. Return false |
| 1219 | 1218 | ** if it is relative. |
| 1220 | 1219 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1192,14 +1192,13 @@ | |
| 1192 | ** |
| 1193 | ** Store the value of the CWD in zBuf which is nBuf bytes in size. |
| 1194 | ** or if zBuf==0, allocate space to hold the result using fossil_malloc(). |
| 1195 | */ |
| 1196 | char *file_getcwd(char *zBuf, int nBuf){ |
| 1197 | char zTemp[2000]; |
| 1198 | if( zBuf==0 ){ |
| 1199 | zBuf = zTemp; |
| 1200 | nBuf = sizeof(zTemp); |
| 1201 | } |
| 1202 | #ifdef _WIN32 |
| 1203 | win32_getcwd(zBuf, nBuf); |
| 1204 | #else |
| 1205 | if( getcwd(zBuf, nBuf-1)==0 ){ |
| @@ -1209,11 +1208,11 @@ | |
| 1209 | fossil_fatal("cannot find current working directory; %s", |
| 1210 | strerror(errno)); |
| 1211 | } |
| 1212 | } |
| 1213 | #endif |
| 1214 | return zBuf==zTemp ? fossil_strdup(zBuf) : zBuf; |
| 1215 | } |
| 1216 | |
| 1217 | /* |
| 1218 | ** Return true if zPath is an absolute pathname. Return false |
| 1219 | ** if it is relative. |
| 1220 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1192,14 +1192,13 @@ | |
| 1192 | ** |
| 1193 | ** Store the value of the CWD in zBuf which is nBuf bytes in size. |
| 1194 | ** or if zBuf==0, allocate space to hold the result using fossil_malloc(). |
| 1195 | */ |
| 1196 | char *file_getcwd(char *zBuf, int nBuf){ |
| 1197 | if( zBuf==0 ){ |
| 1198 | char zTemp[2000]; |
| 1199 | return fossil_strdup(file_getcwd(zTemp, sizeof(zTemp))); |
| 1200 | } |
| 1201 | #ifdef _WIN32 |
| 1202 | win32_getcwd(zBuf, nBuf); |
| 1203 | #else |
| 1204 | if( getcwd(zBuf, nBuf-1)==0 ){ |
| @@ -1209,11 +1208,11 @@ | |
| 1208 | fossil_fatal("cannot find current working directory; %s", |
| 1209 | strerror(errno)); |
| 1210 | } |
| 1211 | } |
| 1212 | #endif |
| 1213 | return zBuf; |
| 1214 | } |
| 1215 | |
| 1216 | /* |
| 1217 | ** Return true if zPath is an absolute pathname. Return false |
| 1218 | ** if it is relative. |
| 1219 |