Fossil SCM

Fix the C89-style related declarations; add a gcc warning to flag such issues, in case these slip through again

developer 2021-06-16 20:24 trunk
Commit da9f362015a3f7766f9dca2259cd8043cdcea9f37c9b2abc5a0d4d1ada2b18ba
+8
--- auto.def
+++ auto.def
@@ -101,10 +101,18 @@
101101
define USE_SYSTEM_SQLITE 0
102102
define USE_LINENOISE 0
103103
define FOSSIL_ENABLE_MINIZ 0
104104
define USE_MMAN_H 0
105105
define USE_SEE 0
106
+
107
+
108
+# Maintain the C89/C90-style order of variable declarations before statements.
109
+# Check if the compiler supports the respective warning flag.
110
+if {[cctest -cflags -Wdeclaration-after-statement]} {
111
+ define-append EXTRA_CFLAGS -Wdeclaration-after-statement
112
+}
113
+
106114
107115
# This procedure is a customized version of "cc-check-function-in-lib",
108116
# that does not modify the LIBS variable. Its use prevents prematurely
109117
# pulling in libraries that will be added later anyhow (e.g. "-ldl").
110118
proc check-function-in-lib {function libs {otherlibs {}}} {
111119
--- auto.def
+++ auto.def
@@ -101,10 +101,18 @@
101 define USE_SYSTEM_SQLITE 0
102 define USE_LINENOISE 0
103 define FOSSIL_ENABLE_MINIZ 0
104 define USE_MMAN_H 0
105 define USE_SEE 0
 
 
 
 
 
 
 
 
106
107 # This procedure is a customized version of "cc-check-function-in-lib",
108 # that does not modify the LIBS variable. Its use prevents prematurely
109 # pulling in libraries that will be added later anyhow (e.g. "-ldl").
110 proc check-function-in-lib {function libs {otherlibs {}}} {
111
--- auto.def
+++ auto.def
@@ -101,10 +101,18 @@
101 define USE_SYSTEM_SQLITE 0
102 define USE_LINENOISE 0
103 define FOSSIL_ENABLE_MINIZ 0
104 define USE_MMAN_H 0
105 define USE_SEE 0
106
107
108 # Maintain the C89/C90-style order of variable declarations before statements.
109 # Check if the compiler supports the respective warning flag.
110 if {[cctest -cflags -Wdeclaration-after-statement]} {
111 define-append EXTRA_CFLAGS -Wdeclaration-after-statement
112 }
113
114
115 # This procedure is a customized version of "cc-check-function-in-lib",
116 # that does not modify the LIBS variable. Its use prevents prematurely
117 # pulling in libraries that will be added later anyhow (e.g. "-ldl").
118 proc check-function-in-lib {function libs {otherlibs {}}} {
119
+1 -1
--- src/add.c
+++ src/add.c
@@ -482,14 +482,14 @@
482482
** _silently_ skips over any names for which
483483
** file_is_reserved_name() returns true or which is in the
484484
** fossil_reserved_name() list. We do not need to warn for those,
485485
** as they're outright verboten. */
486486
if(db_exists("SELECT 1 FROM sfile WHERE win_reserved(pathname)")){
487
+ int reservedCount = 0;
487488
Stmt q = empty_Stmt;
488489
db_prepare(&q,"SELECT pathname FROM sfile "
489490
"WHERE win_reserved(pathname)");
490
- int reservedCount = 0;
491491
while( db_step(&q)==SQLITE_ROW ){
492492
const char * zName = db_column_text(&q, 0);
493493
++reservedCount;
494494
if(allowReservedFlag){
495495
fossil_warning("WARNING: Windows-reserved "
496496
--- src/add.c
+++ src/add.c
@@ -482,14 +482,14 @@
482 ** _silently_ skips over any names for which
483 ** file_is_reserved_name() returns true or which is in the
484 ** fossil_reserved_name() list. We do not need to warn for those,
485 ** as they're outright verboten. */
486 if(db_exists("SELECT 1 FROM sfile WHERE win_reserved(pathname)")){
 
487 Stmt q = empty_Stmt;
488 db_prepare(&q,"SELECT pathname FROM sfile "
489 "WHERE win_reserved(pathname)");
490 int reservedCount = 0;
491 while( db_step(&q)==SQLITE_ROW ){
492 const char * zName = db_column_text(&q, 0);
493 ++reservedCount;
494 if(allowReservedFlag){
495 fossil_warning("WARNING: Windows-reserved "
496
--- src/add.c
+++ src/add.c
@@ -482,14 +482,14 @@
482 ** _silently_ skips over any names for which
483 ** file_is_reserved_name() returns true or which is in the
484 ** fossil_reserved_name() list. We do not need to warn for those,
485 ** as they're outright verboten. */
486 if(db_exists("SELECT 1 FROM sfile WHERE win_reserved(pathname)")){
487 int reservedCount = 0;
488 Stmt q = empty_Stmt;
489 db_prepare(&q,"SELECT pathname FROM sfile "
490 "WHERE win_reserved(pathname)");
 
491 while( db_step(&q)==SQLITE_ROW ){
492 const char * zName = db_column_text(&q, 0);
493 ++reservedCount;
494 if(allowReservedFlag){
495 fossil_warning("WARNING: Windows-reserved "
496
+5 -4
--- src/finfo.c
+++ src/finfo.c
@@ -141,21 +141,22 @@
141141
blob_write_to_file(&record, "-");
142142
blob_reset(&record);
143143
blob_reset(&fname);
144144
}else if( find_option("id","i",0) ){
145145
Blob fname;
146
+ int rid;
146147
const char *zRevision = find_option("revision", "r", 1);
147148
148149
verify_all_options();
149150
150151
if( zRevision==0 ) usage("-i|--id also requires -r|--revision");
151152
if( g.argc!=3 ) usage("-r|--revision REVISION FILENAME");
152153
file_tree_name(g.argv[2], &fname, 0, 1);
153
- int rid = db_int(0, "SELECT rid FROM blob WHERE uuid ="
154
- " (SELECT uuid FROM files_of_checkin(%Q)"
155
- " WHERE filename=%B %s)",
156
- zRevision, &fname, filename_collation());
154
+ rid = db_int(0, "SELECT rid FROM blob WHERE uuid ="
155
+ " (SELECT uuid FROM files_of_checkin(%Q)"
156
+ " WHERE filename=%B %s)",
157
+ zRevision, &fname, filename_collation());
157158
if( rid==0 ) {
158159
fossil_fatal("file not found for revision %s: %s",
159160
zRevision, blob_str(&fname));
160161
}
161162
whatis_rid(rid,0);
162163
--- src/finfo.c
+++ src/finfo.c
@@ -141,21 +141,22 @@
141 blob_write_to_file(&record, "-");
142 blob_reset(&record);
143 blob_reset(&fname);
144 }else if( find_option("id","i",0) ){
145 Blob fname;
 
146 const char *zRevision = find_option("revision", "r", 1);
147
148 verify_all_options();
149
150 if( zRevision==0 ) usage("-i|--id also requires -r|--revision");
151 if( g.argc!=3 ) usage("-r|--revision REVISION FILENAME");
152 file_tree_name(g.argv[2], &fname, 0, 1);
153 int rid = db_int(0, "SELECT rid FROM blob WHERE uuid ="
154 " (SELECT uuid FROM files_of_checkin(%Q)"
155 " WHERE filename=%B %s)",
156 zRevision, &fname, filename_collation());
157 if( rid==0 ) {
158 fossil_fatal("file not found for revision %s: %s",
159 zRevision, blob_str(&fname));
160 }
161 whatis_rid(rid,0);
162
--- src/finfo.c
+++ src/finfo.c
@@ -141,21 +141,22 @@
141 blob_write_to_file(&record, "-");
142 blob_reset(&record);
143 blob_reset(&fname);
144 }else if( find_option("id","i",0) ){
145 Blob fname;
146 int rid;
147 const char *zRevision = find_option("revision", "r", 1);
148
149 verify_all_options();
150
151 if( zRevision==0 ) usage("-i|--id also requires -r|--revision");
152 if( g.argc!=3 ) usage("-r|--revision REVISION FILENAME");
153 file_tree_name(g.argv[2], &fname, 0, 1);
154 rid = db_int(0, "SELECT rid FROM blob WHERE uuid ="
155 " (SELECT uuid FROM files_of_checkin(%Q)"
156 " WHERE filename=%B %s)",
157 zRevision, &fname, filename_collation());
158 if( rid==0 ) {
159 fossil_fatal("file not found for revision %s: %s",
160 zRevision, blob_str(&fname));
161 }
162 whatis_rid(rid,0);
163
+3 -2
--- src/linenoise.c
+++ src/linenoise.c
@@ -1028,21 +1028,22 @@
10281028
static char *linenoiseNoTTY(void) {
10291029
char *line = NULL;
10301030
size_t len = 0, maxlen = 0;
10311031
10321032
while(1) {
1033
+ int c;
10331034
if (len == maxlen) {
1035
+ char *oldval = line;
10341036
if (maxlen == 0) maxlen = 16;
10351037
maxlen *= 2;
1036
- char *oldval = line;
10371038
line = realloc(line,maxlen);
10381039
if (line == NULL) {
10391040
if (oldval) free(oldval);
10401041
return NULL;
10411042
}
10421043
}
1043
- int c = fgetc(stdin);
1044
+ c = fgetc(stdin);
10441045
if (c == EOF || c == '\n') {
10451046
if (c == EOF && len == 0) {
10461047
free(line);
10471048
return NULL;
10481049
} else {
10491050
--- src/linenoise.c
+++ src/linenoise.c
@@ -1028,21 +1028,22 @@
1028 static char *linenoiseNoTTY(void) {
1029 char *line = NULL;
1030 size_t len = 0, maxlen = 0;
1031
1032 while(1) {
 
1033 if (len == maxlen) {
 
1034 if (maxlen == 0) maxlen = 16;
1035 maxlen *= 2;
1036 char *oldval = line;
1037 line = realloc(line,maxlen);
1038 if (line == NULL) {
1039 if (oldval) free(oldval);
1040 return NULL;
1041 }
1042 }
1043 int c = fgetc(stdin);
1044 if (c == EOF || c == '\n') {
1045 if (c == EOF && len == 0) {
1046 free(line);
1047 return NULL;
1048 } else {
1049
--- src/linenoise.c
+++ src/linenoise.c
@@ -1028,21 +1028,22 @@
1028 static char *linenoiseNoTTY(void) {
1029 char *line = NULL;
1030 size_t len = 0, maxlen = 0;
1031
1032 while(1) {
1033 int c;
1034 if (len == maxlen) {
1035 char *oldval = line;
1036 if (maxlen == 0) maxlen = 16;
1037 maxlen *= 2;
 
1038 line = realloc(line,maxlen);
1039 if (line == NULL) {
1040 if (oldval) free(oldval);
1041 return NULL;
1042 }
1043 }
1044 c = fgetc(stdin);
1045 if (c == EOF || c == '\n') {
1046 if (c == EOF && len == 0) {
1047 free(line);
1048 return NULL;
1049 } else {
1050
+2 -1
--- src/wiki.c
+++ src/wiki.c
@@ -1588,10 +1588,11 @@
15881588
void whistory_page(void){
15891589
Stmt q;
15901590
const char *zPageName;
15911591
double rNow;
15921592
int showRid;
1593
+ char zAuthor[64];
15931594
login_check_credentials();
15941595
if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; }
15951596
zPageName = PD("name","");
15961597
style_set_current_feature("wiki");
15971598
style_header("History Of %s", zPageName);
@@ -1629,11 +1630,11 @@
16291630
@ <th>RID</th>
16301631
}
16311632
@ <th>&nbsp;</th>
16321633
@ </tr></thead><tbody>
16331634
rNow = db_double(0.0, "SELECT julianday('now')");
1634
- char zAuthor[64]; memset( zAuthor, 0, sizeof(zAuthor) );
1635
+ memset( zAuthor, 0, sizeof(zAuthor) );
16351636
while( db_step(&q)==SQLITE_ROW ){
16361637
double rMtime = db_column_double(&q, 0);
16371638
const char *zUuid = db_column_text(&q, 1);
16381639
const char *zUser = db_column_text(&q, 2);
16391640
int wrid = db_column_int(&q, 3);
16401641
--- src/wiki.c
+++ src/wiki.c
@@ -1588,10 +1588,11 @@
1588 void whistory_page(void){
1589 Stmt q;
1590 const char *zPageName;
1591 double rNow;
1592 int showRid;
 
1593 login_check_credentials();
1594 if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; }
1595 zPageName = PD("name","");
1596 style_set_current_feature("wiki");
1597 style_header("History Of %s", zPageName);
@@ -1629,11 +1630,11 @@
1629 @ <th>RID</th>
1630 }
1631 @ <th>&nbsp;</th>
1632 @ </tr></thead><tbody>
1633 rNow = db_double(0.0, "SELECT julianday('now')");
1634 char zAuthor[64]; memset( zAuthor, 0, sizeof(zAuthor) );
1635 while( db_step(&q)==SQLITE_ROW ){
1636 double rMtime = db_column_double(&q, 0);
1637 const char *zUuid = db_column_text(&q, 1);
1638 const char *zUser = db_column_text(&q, 2);
1639 int wrid = db_column_int(&q, 3);
1640
--- src/wiki.c
+++ src/wiki.c
@@ -1588,10 +1588,11 @@
1588 void whistory_page(void){
1589 Stmt q;
1590 const char *zPageName;
1591 double rNow;
1592 int showRid;
1593 char zAuthor[64];
1594 login_check_credentials();
1595 if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; }
1596 zPageName = PD("name","");
1597 style_set_current_feature("wiki");
1598 style_header("History Of %s", zPageName);
@@ -1629,11 +1630,11 @@
1630 @ <th>RID</th>
1631 }
1632 @ <th>&nbsp;</th>
1633 @ </tr></thead><tbody>
1634 rNow = db_double(0.0, "SELECT julianday('now')");
1635 memset( zAuthor, 0, sizeof(zAuthor) );
1636 while( db_step(&q)==SQLITE_ROW ){
1637 double rMtime = db_column_double(&q, 0);
1638 const char *zUuid = db_column_text(&q, 1);
1639 const char *zUser = db_column_text(&q, 2);
1640 int wrid = db_column_int(&q, 3);
1641

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button