Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 51d1a12

Browse files
committed
Fix portability issues with functions that don't match their declaration.
1 parent b3fcc81 commit 51d1a12

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

contrib/pg_autovacuum/pg_autovacuum.c

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
FILE *LOGOUTPUT;
1010
char logbuffer[4096];
1111

12-
void
12+
static void
1313
log_entry(const char *logentry)
1414
{
1515
time_t curtime;
@@ -22,10 +22,14 @@ log_entry(const char *logentry)
2222
fprintf(LOGOUTPUT, "[%s] %s\n", timebuffer, logentry);
2323
}
2424

25-
/* Function used to detatch the pg_autovacuum daemon from the tty and go into the background *
26-
* This code is mostly ripped directly from pm_dameonize in postmaster.c *
27-
* with unneeded code removed. */
28-
void
25+
/*
26+
* Function used to detach the pg_autovacuum daemon from the tty and go into
27+
* the background.
28+
*
29+
* This code is mostly ripped directly from pm_dameonize in postmaster.c with
30+
* unneeded code removed.
31+
*/
32+
static void
2933
daemonize()
3034
{
3135
pid_t pid;
@@ -57,7 +61,7 @@ daemonize()
5761
}
5862

5963
/* Create and return tbl_info struct with initialized to values from row or res */
60-
tbl_info *
64+
static tbl_info *
6165
init_table_info(PGresult *res, int row, db_info * dbi)
6266
{
6367
tbl_info *new_tbl = (tbl_info *) malloc(sizeof(tbl_info));
@@ -138,7 +142,7 @@ init_table_info(PGresult *res, int row, db_info * dbi)
138142

139143
/* Set thresholds = base_value + scaling_factor * reltuples
140144
Should be called after a vacuum since vacuum updates values in pg_class */
141-
void
145+
static void
142146
update_table_thresholds(db_info * dbi, tbl_info * tbl, int vacuum_type)
143147
{
144148
PGresult *res = NULL;
@@ -196,7 +200,7 @@ update_table_thresholds(db_info * dbi, tbl_info * tbl, int vacuum_type)
196200
db_disconnect(dbi);
197201
}
198202

199-
void
203+
static void
200204
update_table_list(db_info * dbi)
201205
{
202206
int disconnect = 0;
@@ -296,7 +300,7 @@ update_table_list(db_info * dbi)
296300
}
297301

298302
/* Free memory, and remove the node from the list */
299-
void
303+
static void
300304
remove_table_from_list(Dlelem *tbl_to_remove)
301305
{
302306
tbl_info *tbl = ((tbl_info *) DLE_VAL(tbl_to_remove));
@@ -328,7 +332,7 @@ remove_table_from_list(Dlelem *tbl_to_remove)
328332
}
329333

330334
/* Free the entire table list */
331-
void
335+
static void
332336
free_tbl_list(Dllist *tbl_list)
333337
{
334338
Dlelem *tbl_elem = DLGetHead(tbl_list);
@@ -343,7 +347,7 @@ free_tbl_list(Dllist *tbl_list)
343347
DLFreeList(tbl_list);
344348
}
345349

346-
void
350+
static void
347351
print_table_list(Dllist *table_list)
348352
{
349353
Dlelem *table_elem = DLGetHead(table_list);
@@ -355,7 +359,7 @@ print_table_list(Dllist *table_list)
355359
}
356360
}
357361

358-
void
362+
static void
359363
print_table_info(tbl_info * tbl)
360364
{
361365
sprintf(logbuffer, " table name: %s.%s", tbl->dbi->dbname, tbl->table_name);
@@ -381,7 +385,7 @@ print_table_info(tbl_info * tbl)
381385
/* Beginning of DB Management Functions */
382386

383387
/* init_db_list() creates the db_list and initalizes template1 */
384-
Dllist *
388+
static Dllist *
385389
init_db_list()
386390
{
387391
Dllist *db_list = DLNewList();
@@ -419,7 +423,7 @@ init_db_list()
419423

420424
/* Simple function to create an instance of the dbinfo struct
421425
Initalizes all the pointers and connects to the database */
422-
db_info *
426+
static db_info *
423427
init_dbinfo(char *dbname, Oid oid, long age)
424428
{
425429
db_info *newdbinfo = (db_info *) malloc(sizeof(db_info));
@@ -452,7 +456,7 @@ init_dbinfo(char *dbname, Oid oid, long age)
452456
}
453457

454458
/* Function adds and removes databases from the db_list as appropriate */
455-
void
459+
static void
456460
update_db_list(Dllist *db_list)
457461
{
458462
int disconnect = 0;
@@ -580,7 +584,7 @@ So we do a full database vacuum if age > 1.5billion
580584
return 0 if nothing happened,
581585
return 1 if the database needed a database wide vacuum
582586
*/
583-
int
587+
static int
584588
xid_wraparound_check(db_info * dbi)
585589
{
586590
/*
@@ -602,7 +606,7 @@ xid_wraparound_check(db_info * dbi)
602606
}
603607

604608
/* Close DB connection, free memory, and remove the node from the list */
605-
void
609+
static void
606610
remove_db_from_list(Dlelem *db_to_remove)
607611
{
608612
db_info *dbi = ((db_info *) DLE_VAL(db_to_remove));
@@ -646,7 +650,7 @@ remove_db_from_list(Dlelem *db_to_remove)
646650

647651
/* Function is called before program exit to free all memory
648652
mostly it's just to keep valgrind happy */
649-
void
653+
static void
650654
free_db_list(Dllist *db_list)
651655
{
652656
Dlelem *db_elem = DLGetHead(db_list);
@@ -662,7 +666,7 @@ free_db_list(Dllist *db_list)
662666
DLFreeList(db_list);
663667
}
664668

665-
void
669+
static void
666670
print_db_list(Dllist *db_list, int print_table_lists)
667671
{
668672
Dlelem *db_elem = DLGetHead(db_list);
@@ -674,7 +678,7 @@ print_db_list(Dllist *db_list, int print_table_lists)
674678
}
675679
}
676680

677-
void
681+
static void
678682
print_db_info(db_info * dbi, int print_tbl_list)
679683
{
680684
sprintf(logbuffer, "dbname: %s", (dbi->dbname) ? dbi->dbname : "(null)");
@@ -710,7 +714,7 @@ print_db_info(db_info * dbi, int print_tbl_list)
710714
/* Beginning of misc Functions */
711715

712716
/* Perhaps add some test to this function to make sure that the stats we need are available */
713-
PGconn *
717+
static PGconn *
714718
db_connect(db_info * dbi)
715719
{
716720
PGconn *db_conn =
@@ -729,7 +733,7 @@ db_connect(db_info * dbi)
729733
return db_conn;
730734
} /* end of db_connect() */
731735

732-
void
736+
static void
733737
db_disconnect(db_info * dbi)
734738
{
735739
if (dbi->conn != NULL)
@@ -739,7 +743,7 @@ db_disconnect(db_info * dbi)
739743
}
740744
}
741745

742-
int
746+
static int
743747
check_stats_enabled(db_info * dbi)
744748
{
745749
PGresult *res;
@@ -754,7 +758,7 @@ check_stats_enabled(db_info * dbi)
754758
return ret;
755759
}
756760

757-
PGresult *
761+
static PGresult *
758762
send_query(const char *query, db_info * dbi)
759763
{
760764
PGresult *res;
@@ -795,7 +799,7 @@ send_query(const char *query, db_info * dbi)
795799
} /* End of send_query() */
796800

797801

798-
void
802+
static void
799803
free_cmd_args()
800804
{
801805
if (args != NULL)
@@ -808,7 +812,7 @@ free_cmd_args()
808812
}
809813
}
810814

811-
cmd_args *
815+
static cmd_args *
812816
get_cmd_args(int argc, char *argv[])
813817
{
814818
int c;
@@ -902,7 +906,7 @@ get_cmd_args(int argc, char *argv[])
902906
return args;
903907
}
904908

905-
void
909+
static void
906910
usage()
907911
{
908912
int i = 0;
@@ -937,7 +941,7 @@ usage()
937941
fprintf(stderr, " [-h] help (Show this output)\n");
938942
}
939943

940-
void
944+
static void
941945
print_cmd_args()
942946
{
943947
sprintf(logbuffer, "Printing command_args");

0 commit comments

Comments
 (0)