From 36d5b322389b32b098ce6ec2e783831a1f375298 Mon Sep 17 00:00:00 2001 From: Teemu Toivola Date: Fri, 28 Jun 2019 18:19:31 +0300 Subject: [PATCH] separate debug error prints from regular error prints --- src/dbsql.c | 10 +++++----- src/fs.c | 16 ++++++++-------- src/ifinfo.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/dbsql.c b/src/dbsql.c index 97957d5..0ffc4f3 100644 --- a/src/dbsql.c +++ b/src/dbsql.c @@ -42,7 +42,7 @@ int db_open(const int createifnotfound, const int readonly) createdb = 1; } else { if (debug) - printf("Error: Handling database \"%s\" failed: %s\n", dbfilename, strerror(errno)); + printf("Error (debug): Handling database \"%s\" failed: %s\n", dbfilename, strerror(errno)); return 0; } } else { @@ -67,7 +67,7 @@ int db_open(const int createifnotfound, const int readonly) if (rc) { db_errcode = rc; if (debug) - printf("Error: Can't open database \"%s\": %s\n", dbfilename, sqlite3_errmsg(db)); + printf("Error (debug): Can't open database \"%s\": %s\n", dbfilename, sqlite3_errmsg(db)); return 0; } else { if (debug) @@ -84,7 +84,7 @@ int db_open(const int createifnotfound, const int readonly) #endif if (!db_create()) { if (debug) - printf("Error: Creating database \"%s\" structure failed\n", dbfilename); + printf("Error (debug): Creating database \"%s\" structure failed\n", dbfilename); db_close(); return 0; } else { @@ -92,7 +92,7 @@ int db_open(const int createifnotfound, const int readonly) printf("Database \"%s\" structure created\n", dbfilename); if (!db_setinfo("dbversion", SQLDBVERSION, 1)) { if (debug) - printf("Error: Writing version info to database \"%s\" failed\n", dbfilename); + printf("Error (debug): Writing version info to database \"%s\" failed\n", dbfilename); db_close(); return 0; } @@ -261,7 +261,7 @@ int db_close(void) } else { db_errcode = rc; if (debug) - printf("Error: Closing database failed (%d): %s\n", rc, sqlite3_errmsg(db)); + printf("Error (debug): Closing database failed (%d): %s\n", rc, sqlite3_errmsg(db)); return 0; } } diff --git a/src/fs.c b/src/fs.c index 5991141..06aa775 100644 --- a/src/fs.c +++ b/src/fs.c @@ -16,7 +16,7 @@ int fileexists(const char *file) return 0; } if (debug) - printf("Error: stat() \"%s\": %s\n", file, strerror(errno)); + printf("Error (debug): stat() \"%s\": %s\n", file, strerror(errno)); } return 1; } @@ -29,7 +29,7 @@ int mkpath(const char *dir, const mode_t mode) if (!strlen(dir)) { if (debug) - printf("Error: mkpath(), no directory given\n"); + printf("Error (debug): mkpath(), no directory given\n"); return 0; } @@ -63,7 +63,7 @@ int mkpath(const char *dir, const mode_t mode) if (!direxists(tmp)) { if (mkdir(tmp, mode) != 0) { if (debug) - printf("Error: mkdir() \"%s\": %s\n", tmp, strerror(errno)); + printf("Error (debug): mkdir() \"%s\": %s\n", tmp, strerror(errno)); ret = 0; break; } @@ -74,7 +74,7 @@ int mkpath(const char *dir, const mode_t mode) if (ret) { if (mkdir(tmp, mode) != 0) { if (debug) - printf("Error: mkdir() \"%s\": %s\n", tmp, strerror(errno)); + printf("Error (debug): mkdir() \"%s\": %s\n", tmp, strerror(errno)); ret = 0; } else if (debug) { printf("created: %s\n", tmp); @@ -189,7 +189,7 @@ void updatedirownerid(const char *dir, const uid_t uid, const gid_t gid) if (statbuf.st_uid != uid || statbuf.st_gid != gid) { if (fchown(dir_fd, uid, gid) != 0) { if (debug) - printf("Error: updatedirowner() chown() \"%s\": %s\n", dir, strerror(errno)); + printf("Error (debug): updatedirowner() chown() \"%s\": %s\n", dir, strerror(errno)); close(dir_fd); return; } else { @@ -200,7 +200,7 @@ void updatedirownerid(const char *dir, const uid_t uid, const gid_t gid) if ((d = fdopendir(dir_fd)) == NULL) { if (debug) - printf("Error: updatedirowner() diropen() \"%s\": %s\n", dir, strerror(errno)); + printf("Error (debug): updatedirowner() diropen() \"%s\": %s\n", dir, strerror(errno)); close(dir_fd); return; } @@ -219,7 +219,7 @@ void updatedirownerid(const char *dir, const uid_t uid, const gid_t gid) if (statbuf.st_uid != uid || statbuf.st_gid != gid) { if (fchown(file_fd, uid, gid) != 0) { if (debug) - printf("Error: chown() \"%s\": %s\n", entryname, strerror(errno)); + printf("Error (debug): chown() \"%s\": %s\n", entryname, strerror(errno)); } else { if (debug) printf("\"%s\" chown completed\n", entryname); @@ -273,7 +273,7 @@ int getdirowner(const char *dir, uid_t *uid, gid_t *gid) if (stat(dir, &statbuf) != 0) { if (debug) - printf("Error: stat() \"%s\": %s\n", dir, strerror(errno)); + printf("Error (debug): stat() \"%s\": %s\n", dir, strerror(errno)); return 0; } diff --git a/src/ifinfo.c b/src/ifinfo.c index 355e2a4..a058527 100644 --- a/src/ifinfo.c +++ b/src/ifinfo.c @@ -213,7 +213,7 @@ int readproc(const char *iface) if ((fp = fopen(PROCNETDEV, "r")) == NULL) { if (debug) - printf("Error: Unable to read %s: %s\n", PROCNETDEV, strerror(errno)); + printf("Error (debug): Unable to read %s: %s\n", PROCNETDEV, strerror(errno)); return 0; } -- 2.40.0