diff --git a/src/apps/bin/chkbfs/chkbfs.cpp b/src/apps/bin/chkbfs/chkbfs.cpp index 21f1c9c576..71f3d7fcdf 100644 --- a/src/apps/bin/chkbfs/chkbfs.cpp +++ b/src/apps/bin/chkbfs/chkbfs.cpp @@ -27,7 +27,7 @@ openDevice(const char *name) fs_info info; if (fs_stat_dev(volume, &info) < B_OK) { - fprintf(stderr, "%s: could not stat device: %s\n", gProgramName, name, errno); + fprintf(stderr, "%s: could not stat device: %s: %s\n", gProgramName, name, strerror(errno)); return errno; } @@ -212,7 +212,7 @@ main(int argc, char **argv) } // print stats - printf("checked %ld nodes, %Ld blocks not allocated, %Ld blocks already set, %Ld blocks could be freed\n", + printf("checked %Ld nodes, %Ld blocks not allocated, %Ld blocks already set, %Ld blocks could be freed\n", nodes, control.stats.missing, control.stats.already_set, control.stats.freed); printf("\tfiles\t\t%Ld\n\tdirectories\t%Ld\n\tattributes\t%Ld\n\tattr. dirs\t%Ld\n\tindices\t\t%Ld\n", files, directories, attributes, attributeDirectories, indices); diff --git a/src/apps/bin/chop.c b/src/apps/bin/chop.c index afa7efa867..bcde16b471 100644 --- a/src/apps/bin/chop.c +++ b/src/apps/bin/chop.c @@ -40,6 +40,8 @@ #include #include +#include +#include #include #include #include @@ -180,13 +182,13 @@ chop_file(int fdin, char *fname, off_t fsize) bool open_next_file = true; // when to open a new output file char fnameN[256]; // name of the current output file (file01, file02, etc.) int index = 0; // used to generate the next output file name - int fdout; // output file descriptor + int fdout = -1; // output file descriptor ssize_t got; // size of the current data block -- i.e. from the last read() ssize_t put; // number of bytes just written -- i.e. from the last write() ssize_t needed; // how many bytes we can safely write to the current output file ssize_t avail; // how many bytes we can safely grab from the current data block - off_t curr_written; // number of bytes written to the current output file + off_t curr_written = 0; // number of bytes written to the current output file off_t total_written = 0; // total bytes written out to all output files char *beg = Block; // pointer to the beginning of the block data to be written out diff --git a/src/apps/bin/clipboard.cpp b/src/apps/bin/clipboard.cpp index 4b2b0adabb..5d92e43ed5 100644 --- a/src/apps/bin/clipboard.cpp +++ b/src/apps/bin/clipboard.cpp @@ -158,6 +158,9 @@ int main( int argc, char **argv ) case Arguments::READ: Clipboard::Read( argv[2] ); break; + default: //Shouldn't happen + Status::Code = B_BAD_VALUE; + break; } } } diff --git a/src/apps/bin/df.cpp b/src/apps/bin/df.cpp index 8483e176d3..b2df05f197 100644 --- a/src/apps/bin/df.cpp +++ b/src/apps/bin/df.cpp @@ -205,14 +205,14 @@ void PrintBlocks (int64 blocks, int64 blocksize, bool human) } else { double fblocks = ((double)blocks) * (blocksize / 1024); if (fblocks < 1024) { - sprintf(temp, "%.1LfK", fblocks); + sprintf(temp, "%.1fK", fblocks); } else { fblocks = (((double)blocks) / 1024) * (blocksize / 1024);; if (fblocks < 1024) { - sprintf(temp, "%.1LfM", fblocks); + sprintf(temp, "%.1fM", fblocks); } else { fblocks = (((double)blocks) / (1024*1024)) * (blocksize / 1024); - sprintf(temp, "%.1LfG", fblocks); + sprintf(temp, "%.1fG", fblocks); } } } diff --git a/src/apps/bin/eject.c b/src/apps/bin/eject.c index fda14cc161..9872b90ba2 100644 --- a/src/apps/bin/eject.c +++ b/src/apps/bin/eject.c @@ -19,7 +19,7 @@ #include #include -int usage(char *prog) +static int usage(char *prog) { printf("usage: eject [-q|-l|-s] /dev/disk/.../raw\n"); printf(" eject the device, or:\n"); diff --git a/src/apps/bin/hd.c b/src/apps/bin/hd.c index 77fe03980a..b8b74d76ab 100644 --- a/src/apps/bin/hd.c +++ b/src/apps/bin/hd.c @@ -14,6 +14,8 @@ #include #include +#include +#include #include #include #include @@ -136,7 +138,7 @@ dump_file(FILE *fp) void display(uint32 offset, uint8 *data) { - printf("%08x ", offset); + printf("%08lx ", offset); printf(" %s ", hexbytes(data)); printf("%16s ", printable(data)); diff --git a/src/apps/bin/listdev/cm_wrapper.c b/src/apps/bin/listdev/cm_wrapper.c index 9e5bcba92e..1d36b81152 100644 --- a/src/apps/bin/listdev/cm_wrapper.c +++ b/src/apps/bin/listdev/cm_wrapper.c @@ -5,6 +5,7 @@ #include +#include "cm_wrapper.h" #include "config_driver.h" static int fd; diff --git a/src/apps/bin/listdev/listdev.c b/src/apps/bin/listdev/listdev.c index 97895b914a..9f87f11cd9 100644 --- a/src/apps/bin/listdev/listdev.c +++ b/src/apps/bin/listdev/listdev.c @@ -8,6 +8,7 @@ #include #include +#include "cm_wrapper.h" #include "config_driver.h" #define NEXT_POSSIBLE(c) \ @@ -64,7 +65,7 @@ dump_device_configuration(struct device_configuration *c) for (i=0;idevtype.base < 13) ? base_desc[info->devtype.base] : "Unknown"); @@ -183,7 +184,7 @@ dump_device_info(struct device_info *info, struct device_configuration *current, printf("Currently unconfigured.\n"); } - printf("%x configurations\n", possible->num_possible); + printf("%lx configurations\n", possible->num_possible); config = possible->possible + 0; for (i=0;inum_possible;i++) { printf("\nPossible configuration #%d: ", i); diff --git a/src/apps/bin/listimage.c b/src/apps/bin/listimage.c index 6ce5550ce2..d10ba7cb3c 100644 --- a/src/apps/bin/listimage.c +++ b/src/apps/bin/listimage.c @@ -51,16 +51,16 @@ list_image_info(team_id id) status = get_team_info(id, &teamInfo); if (status < B_OK) { - printf("\nCould not retrieve information about team %ld: \n", id, strerror(status)); + printf("\nCould not retrieve information about team %ld: %s\n", id, strerror(status)); return; } - printf("\nTEAM %4d (%s):\n", id, teamInfo.args); + printf("\nTEAM %4ld (%s):\n", id, teamInfo.args); printf(" ID name text data seq# init#\n"); printf("--------------------------------------------------------------------------------------------------------\n"); while ((status = get_next_image_info(id, &cookie, &imageInfo)) == B_OK) { - printf("%5d %64s %.8x %.8x %4d %10u\n", + printf("%5ld %64s %p %p %4ld %10lu\n", imageInfo.id, imageInfo.name, imageInfo.text, diff --git a/src/apps/bin/listport.c b/src/apps/bin/listport.c index aa9ad23eae..6bd4a6faf4 100644 --- a/src/apps/bin/listport.c +++ b/src/apps/bin/listport.c @@ -57,7 +57,7 @@ show_port_totals() left = max - used; - printf("port: total: %5d, used: %5d, left: %5d\n", max, used, left); + printf("port: total: %5ld, used: %5ld, left: %5ld\n", max, used, left); } @@ -69,16 +69,16 @@ list_team_ports(team_id id) team_info this_team; if (get_team_info(id, &this_team) == B_BAD_TEAM_ID) { - printf("\nteam %d unknown\n", id); + printf("\nteam %ld unknown\n", id); return; } - printf("\nTEAM %4d (%s):\n", id, this_team.args); + printf("\nTEAM %4ld (%s):\n", id, this_team.args); printf(" ID name capacity queued\n"); printf("----------------------------------------------------\n"); while (get_next_port_info(id, &cookie, &this_port) == B_OK) { - printf("%5d %28s %8d %6d\n", + printf("%5ld %28s %8ld %6ld\n", this_port.port, this_port.name, this_port.capacity, diff --git a/src/apps/bin/listsem.c b/src/apps/bin/listsem.c index 5e7cb4f19c..6fdb102054 100644 --- a/src/apps/bin/listsem.c +++ b/src/apps/bin/listsem.c @@ -32,20 +32,21 @@ */ #include +#include #include -void list_sems(team_info *tinfo) +static void list_sems(team_info *tinfo) { sem_info info; int32 cookie = 0; - printf("TEAM %d (%s):\n", tinfo->team, tinfo->args ); + printf("TEAM %ld (%s):\n", tinfo->team, tinfo->args ); printf(" ID name count\n"); printf("---------------------------------------------\n"); while (get_next_sem_info(tinfo->team, &cookie, &info) == B_OK) { - printf("%7d%31s%7d\n", info.sem ,info.name , info.count ); + printf("%7ld%31s%7ld\n", info.sem ,info.name , info.count ); } printf("\n"); } @@ -59,7 +60,7 @@ int main(int argc, char **argv) // show up some stats first... get_system_info(&sysinfo); - printf("sem: total: %5i, used: %5i, left: %5i\n\n", sysinfo.max_sems, sysinfo.used_sems, sysinfo.max_sems - sysinfo.used_sems); + printf("sem: total: %5li, used: %5li, left: %5li\n\n", sysinfo.max_sems, sysinfo.used_sems, sysinfo.max_sems - sysinfo.used_sems); if (argc == 1) { while (get_next_team_info( &cook, &tinfo) == B_OK) diff --git a/src/apps/bin/mount.c b/src/apps/bin/mount.c index 88b3f54cf7..661f8b2a58 100644 --- a/src/apps/bin/mount.c +++ b/src/apps/bin/mount.c @@ -17,7 +17,7 @@ #include -void +static void usage(const char *programName) { diff --git a/src/apps/bin/pc/pc.c b/src/apps/bin/pc/pc.c index 2c2192cc68..efd90924a3 100644 --- a/src/apps/bin/pc/pc.c +++ b/src/apps/bin/pc/pc.c @@ -173,7 +173,7 @@ int (*set_var_lookup_hook(int (*func)(char *name, ULONG *val))) ULONG last_result = 0; -int +static int special_vars(char *name, ULONG *val) { if (strcmp(name, "time") == 0) @@ -213,7 +213,7 @@ main(int argc, char *argv[]) casting and comparisons we can determine if a value will fit in a 32 bit quantity and only print that. */ -void +static void print_result(ULONG value) { int i; @@ -253,7 +253,7 @@ void parse_args(int argc, char *argv[]) { int i, len; - char *buff, *fmt_str; + char *buff; ULONG value; for(i=1, len=0; i < argc; i++) @@ -279,7 +279,6 @@ parse_args(int argc, char *argv[]) void do_input(void) { - int ret; ULONG value; char buff[256], *ptr; @@ -331,8 +330,8 @@ parse_expression(char *str) ULONG assignment_expr(char **str) { - ULONG val, sum = 0; - char op, *orig_str; + ULONG val; + char *orig_str; char *var_name; variable *v; @@ -838,7 +837,7 @@ get_value(char **str) if (**str == SINGLE_QUOTE) /* a character constant */ { - int i; + unsigned int i; *str = *str + 1; /* advance over the leading quote */ val = 0; @@ -854,7 +853,7 @@ get_value(char **str) if (**str != SINGLE_QUOTE) /* constant must have been too long */ { fprintf(stderr, "Warning: character constant not terminated or too " - "long (max len == %d bytes)\n", sizeof(LONG)); + "long (max len == %ld bytes)\n", sizeof(LONG)); while(**str && **str != SINGLE_QUOTE) *str += 1; } diff --git a/src/apps/bin/prio.c b/src/apps/bin/prio.c index 94788f74a3..ff6db01392 100644 --- a/src/apps/bin/prio.c +++ b/src/apps/bin/prio.c @@ -14,6 +14,7 @@ #include #include +#include int main(int argc, char **argv) { diff --git a/src/apps/bin/ps.c b/src/apps/bin/ps.c index a4c6af1f0e..c2b5fc7359 100644 --- a/src/apps/bin/ps.c +++ b/src/apps/bin/ps.c @@ -48,17 +48,17 @@ int main(int argc, char **argv) if (strstr(p, string_to_match) == NULL) continue; } - printf("%s (team %d) (uid %d) (gid %d)\n", teaminfo.args, teaminfo.team, teaminfo.uid, teaminfo.gid); + printf("%s (team %ld) (uid %d) (gid %d)\n", teaminfo.args, teaminfo.team, teaminfo.uid, teaminfo.gid); thcookie = 0; while ((ret = get_next_thread_info(teaminfo.team, &thcookie, &thinfo)) >= B_OK) { if (thinfo.state < B_THREAD_RUNNING || thinfo.state >B_THREAD_WAITING) thstate = "???"; else thstate = states[thinfo.state-1]; - printf("%7ld %20s %3s %3d %7lli %7lli ", thinfo.thread, thinfo.name, thstate, thinfo.priority, thinfo.user_time/1000, thinfo.kernel_time/1000); + printf("%7ld %20s %3s %3ld %7lli %7lli ", thinfo.thread, thinfo.name, thstate, thinfo.priority, thinfo.user_time/1000, thinfo.kernel_time/1000); if (thinfo.state == B_THREAD_WAITING) { get_sem_info(thinfo.sem, &sinfo); - printf("%s(%d)\n", sinfo.name, sinfo.sem); + printf("%s(%ld)\n", sinfo.name, sinfo.sem); } else puts(""); } @@ -66,9 +66,9 @@ int main(int argc, char **argv) puts(""); // system stats get_system_info(&sysinfo); - printf("%ik (%li bytes) total memory\n", sysinfo.max_pages*B_PAGE_SIZE/1024, sysinfo.max_pages*B_PAGE_SIZE); - printf("%ik (%li bytes) currently committed\n", sysinfo.used_pages*B_PAGE_SIZE/1024, sysinfo.used_pages*B_PAGE_SIZE); - printf("%ik (%li bytes) currently available\n", (sysinfo.max_pages-sysinfo.used_pages)*B_PAGE_SIZE/1024, (sysinfo.max_pages-sysinfo.used_pages)*B_PAGE_SIZE); + printf("%lik (%li bytes) total memory\n", sysinfo.max_pages*B_PAGE_SIZE/1024, sysinfo.max_pages*B_PAGE_SIZE); + printf("%lik (%li bytes) currently committed\n", sysinfo.used_pages*B_PAGE_SIZE/1024, sysinfo.used_pages*B_PAGE_SIZE); + printf("%lik (%li bytes) currently available\n", (sysinfo.max_pages-sysinfo.used_pages)*B_PAGE_SIZE/1024, (sysinfo.max_pages-sysinfo.used_pages)*B_PAGE_SIZE); printf("%2.1f%% memory utilisation\n", (float)100 * sysinfo.used_pages / sysinfo.max_pages); return 0; } diff --git a/src/apps/bin/renice.c b/src/apps/bin/renice.c index 177941fa33..6ca5ed1192 100644 --- a/src/apps/bin/renice.c +++ b/src/apps/bin/renice.c @@ -15,6 +15,7 @@ #include #include +#include /* Notes: @@ -49,18 +50,18 @@ prio is locked into one pid, then the priority. */ // returns an equivalent UNIX priority for a given BeOS priority. -int32 prio_be_to_unix(int32 prio) +static int32 prio_be_to_unix(int32 prio) { return (prio > 10)?(- (20 * (prio - 10)) / 110):(2 * (10 - prio)); } // returns an equivalent BeOS priority for a given UNIX priority. -int32 prio_unix_to_be(int32 prio) +static int32 prio_unix_to_be(int32 prio) { return (prio > 0)?(10 - (prio/2)):(10 + 110 * (-prio) / 20); } -status_t renice_thread(int32 prio, int32 increment, bool use_be_prio, thread_id th) +static status_t renice_thread(int32 prio, int32 increment, bool use_be_prio, thread_id th) { thread_info thinfo; diff --git a/src/apps/bin/rescan.c b/src/apps/bin/rescan.c index b67b8f13bc..e5095fac0f 100644 --- a/src/apps/bin/rescan.c +++ b/src/apps/bin/rescan.c @@ -1,6 +1,7 @@ #include // for O_WRONLY #include +#include // 2002, François Revol // technical reference: diff --git a/src/apps/bin/roster.cpp b/src/apps/bin/roster.cpp index c8f146d027..d875dfd68a 100644 --- a/src/apps/bin/roster.cpp +++ b/src/apps/bin/roster.cpp @@ -25,7 +25,6 @@ bool OutputTeam( void * item_p ) static uint32 i = 0u; // counter app_info info; - app_info *pinfo = &info; // Roster stores team_id not team_id * team_id id = reinterpret_cast( item_p ); diff --git a/src/apps/bin/shutdown.cpp b/src/apps/bin/shutdown.cpp index f0902e7118..0846ffc264 100644 --- a/src/apps/bin/shutdown.cpp +++ b/src/apps/bin/shutdown.cpp @@ -409,7 +409,7 @@ int main(int argc, char **argv) if (time_to_sleep > 0) { unsigned int left; - thread_id BApp_thread; + thread_id BApp_thread = -1; signal(SIGUSR1, handle_usr1); diff --git a/src/apps/bin/sysinfo.c b/src/apps/bin/sysinfo.c index 31863b5cc6..63ca6ed9cc 100644 --- a/src/apps/bin/sysinfo.c +++ b/src/apps/bin/sysinfo.c @@ -12,6 +12,7 @@ #include #include +#include #include static const int cache_desc_values[] = { @@ -241,7 +242,7 @@ static void dump_cpu(system_info *info) ret = get_cpuid(&cpuii[0], 0, i); if (ret != B_OK) { - fprintf(stderr, "cpuid_info(, %ld, %ld): error 0x%08lx\n", 0, i, ret); + fprintf(stderr, "cpuid_info(, %d, %d): error 0x%08lx\n", 0, i, ret); break; } max_eax = cpuii[0].eax_0.max_eax; @@ -250,7 +251,7 @@ static void dump_cpu(system_info *info) for (j = 1; j <= max_eax && j < 5; j++) { ret = get_cpuid(&cpuii[j], j, i); if (ret != B_OK) { - fprintf(stderr, "cpuid_info(, %ld, %ld): error 0x%08lx\n", j, i, ret); + fprintf(stderr, "cpuid_info(, %d, %d): error 0x%08lx\n", j, i, ret); break; } } @@ -266,7 +267,7 @@ static void dump_cpu(system_info *info) if (check_extended) { ret = get_cpuid(&cpuiie[0], 0x80000000, i); if (ret != B_OK) { - fprintf(stderr, "cpuid_info(, %ld, %ld): error 0x%08lx\n", 0x80000000, i, ret); + fprintf(stderr, "cpuid_info(, %d, %d): error 0x%08lx\n", 0x80000000, i, ret); break; } max_eeax = cpuiie[0].eax_0.max_eax & 0x0ff; @@ -274,7 +275,7 @@ static void dump_cpu(system_info *info) for (j = 1; j <= max_eeax && j < 9; j++) { ret = get_cpuid(&cpuiie[j], 0x80000000+j, i); if (ret != B_OK) { - fprintf(stderr, "cpuid_info(, %ld, %ld): error 0x%08lx\n", 0x80000000+j, i, ret); + fprintf(stderr, "cpuid_info(, %d, %d): error 0x%08lx\n", 0x80000000+j, i, ret); break; } } @@ -284,7 +285,7 @@ static void dump_cpu(system_info *info) printf("CPU #%d: %.12s\n", i, cpuii[0].eax_0.vendorid); if (max_eax == 0) continue; - printf("\ttype %u, family %u, model %u, stepping %u, features 0x%08x\n", + printf("\ttype %u, family %u, model %u, stepping %u, features 0x%08lx\n", cpuii[1].eax_1.type, cpuii[1].eax_1.family, cpuii[1].eax_1.model, @@ -293,7 +294,7 @@ static void dump_cpu(system_info *info) /* Extended CPUID */ if (max_eeax > 0) { printf("\tExtended information:\n"); - printf("\ttype %u, family %u, model %u, stepping %u, features 0x%08x\n", + printf("\ttype %u, family %u, model %u, stepping %u, features 0x%08lx\n", cpuiie[1].eax_1.type, cpuiie[1].eax_1.family, cpuiie[1].eax_1.model, @@ -336,7 +337,7 @@ static void dump_cpu(system_info *info) break; ret = get_cpuid(&cpuii[2], 2, i); if (ret != B_OK) { - fprintf(stderr, "cpuid_info(, %ld, %ld): error 0x%08lx\n", 2, i, ret); + fprintf(stderr, "cpuid_info(, %d, %d): error 0x%08lx\n", 2, i, ret); break; } diff --git a/src/apps/bin/unchop.c b/src/apps/bin/unchop.c index 32a361b24c..93b214b037 100644 --- a/src/apps/bin/unchop.c +++ b/src/apps/bin/unchop.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -23,7 +24,7 @@ void append_file (int, int); void do_unchop (char *, char *); void replace (char *, char *); -char *temp_file (); +char *temp_file (void); void usage (void); bool valid_file (char *); @@ -166,7 +167,7 @@ replace(char *origfile, char *newfile) char * -temp_file() +temp_file(void) { // creates a new, temporary file and returns its name