projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix warning
[oweals/busybox.git]
/
md5sum.c
diff --git
a/md5sum.c
b/md5sum.c
index 3458f2e059d562935de1425eda8933619a1d6783..ac34623346ed9c0027cd192e005a008f5d00785d 100644
(file)
--- a/
md5sum.c
+++ b/
md5sum.c
@@
-20,11
+20,11
@@
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
/* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
/* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
-#include "busybox.h"
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <getopt.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <getopt.h>
+#include "busybox.h"
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
#undef TRUE
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
#undef TRUE
@@
-91,7
+91,7
@@
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _MD5_H
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _MD5_H
-#define _MD5_H 1
+static const int _MD5_H = 1;
#include <stdio.h>
#include <stdio.h>
@@
-251,7
+251,7
@@
void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
int md5_stream(FILE *stream, void *resblock)
{
/* Important: BLOCKSIZE must be a multiple of 64. */
int md5_stream(FILE *stream, void *resblock)
{
/* Important: BLOCKSIZE must be a multiple of 64. */
-#define BLOCKSIZE 4096
+static const int BLOCKSIZE = 4096;
struct md5_ctx ctx;
char buffer[BLOCKSIZE + 72];
size_t sum;
struct md5_ctx ctx;
char buffer[BLOCKSIZE + 72];
size_t sum;
@@
-529,7
+529,7
@@
void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
/* The minimum length of a valid digest line in a file produced
by `md5sum FILE' and read by `md5sum -c'. This length does
not include any newline character at the end of a line. */
/* The minimum length of a valid digest line in a file produced
by `md5sum FILE' and read by `md5sum -c'. This length does
not include any newline character at the end of a line. */
-
#define MIN_DIGEST_LINE_LENGTH 35
/* 32 - message digest length
+
static const int MIN_DIGEST_LINE_LENGTH = 35;
/* 32 - message digest length
2 - blank and binary indicator
1 - minimum filename length */
2 - blank and binary indicator
1 - minimum filename length */
@@
-719,7
+719,7
@@
static int md5_check(const char *checkfile_name)
if (split_3(line, line_length, &md5num, &binary, &filename)
|| !hex_digits(md5num)) {
if (warn) {
if (split_3(line, line_length, &md5num, &binary, &filename)
|| !hex_digits(md5num)) {
if (warn) {
- error_msg("%s: %lu: improperly formatted MD5 checksum line
\n
",
+ error_msg("%s: %lu: improperly formatted MD5 checksum line",
checkfile_name, (unsigned long) line_number);
}
} else {
checkfile_name, (unsigned long) line_number);
}
} else {
@@
-764,7
+764,7
@@
static int md5_check(const char *checkfile_name)
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
if (ferror(checkfile_stream)) {
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
if (ferror(checkfile_stream)) {
- error_msg("%s: read error
\n", checkfile_name); /* */
+ error_msg("%s: read error
", checkfile_name);
return FALSE;
}
return FALSE;
}
@@
-775,7
+775,7
@@
static int md5_check(const char *checkfile_name)
if (n_properly_formated_lines == 0) {
/* Warn if no tests are found. */
if (n_properly_formated_lines == 0) {
/* Warn if no tests are found. */
- error_msg("%s: no properly formatted MD5 checksum lines found
\n
",
+ error_msg("%s: no properly formatted MD5 checksum lines found",
checkfile_name);
return FALSE;
} else {
checkfile_name);
return FALSE;
} else {
@@
-784,13
+784,13
@@
static int md5_check(const char *checkfile_name)
- n_open_or_read_failures);
if (n_open_or_read_failures > 0) {
- n_open_or_read_failures);
if (n_open_or_read_failures > 0) {
- error_msg("WARNING: %d of %d listed files could not be read
\n
",
+ error_msg("WARNING: %d of %d listed files could not be read",
n_open_or_read_failures, n_properly_formated_lines);
return FALSE;
}
if (n_mismatched_checksums > 0) {
n_open_or_read_failures, n_properly_formated_lines);
return FALSE;
}
if (n_mismatched_checksums > 0) {
- error_msg("WARNING: %d of %d computed checksums did NOT match
\n
",
+ error_msg("WARNING: %d of %d computed checksums did NOT match",
n_mismatched_checksums, n_computed_checkums);
return FALSE;
}
n_mismatched_checksums, n_computed_checkums);
return FALSE;
}
@@
-819,8
+819,6
@@
int md5sum_main(int argc,
if (string == NULL)
string = (char **) xmalloc ((argc - 1) * sizeof (char *));
if (string == NULL)
string = (char **) xmalloc ((argc - 1) * sizeof (char *));
- if (optarg == NULL)
- optarg = "";
string[n_strings++] = optarg;
break;
}
string[n_strings++] = optarg;
break;
}
@@
-850,31
+848,31
@@
int md5sum_main(int argc,
break;
default:
break;
default:
-
usage(md5sum_usage
);
+
show_usage(
);
}
}
if (file_type_specified && do_check) {
}
}
if (file_type_specified && do_check) {
- error_msg_and_die("the -b and -t options are meaningless when verifying checksums
\n
");
+ error_msg_and_die("the -b and -t options are meaningless when verifying checksums");
}
if (n_strings > 0 && do_check) {
}
if (n_strings > 0 && do_check) {
- error_msg_and_die("the -g and -c options are mutually exclusive
\n
");
+ error_msg_and_die("the -g and -c options are mutually exclusive");
}
if (status_only && !do_check) {
}
if (status_only && !do_check) {
- error_msg_and_die("the -s option is meaningful only when verifying checksums
\n
");
+ error_msg_and_die("the -s option is meaningful only when verifying checksums");
}
if (warn && !do_check) {
}
if (warn && !do_check) {
- error_msg_and_die("the -w option is meaningful only when verifying checksums
\n
");
+ error_msg_and_die("the -w option is meaningful only when verifying checksums");
}
if (n_strings > 0) {
size_t i;
if (optind < argc) {
}
if (n_strings > 0) {
size_t i;
if (optind < argc) {
- error_msg_and_die("no files may be specified when using -g
\n
");
+ error_msg_and_die("no files may be specified when using -g");
}
for (i = 0; i < n_strings; ++i) {
size_t cnt;
}
for (i = 0; i < n_strings; ++i) {
size_t cnt;
@@
-887,7
+885,7
@@
int md5sum_main(int argc,
}
} else if (do_check) {
if (optind + 1 < argc) {
}
} else if (do_check) {
if (optind + 1 < argc) {
- error_msg("only one argument may be specified when using -c
\n
");
+ error_msg("only one argument may be specified when using -c");
}
err = md5_check ((optind == argc) ? "-" : argv[optind]);
}
err = md5_check ((optind == argc) ? "-" : argv[optind]);
@@
-901,7
+899,12
@@
int md5sum_main(int argc,
fail = md5_file (file, binary, md5buffer);
err |= fail;
fail = md5_file (file, binary, md5buffer);
err |= fail;
- if (!fail) {
+ if (!fail && STREQ(file, "-")) {
+ size_t i;
+ for (i = 0; i < 16; ++i)
+ printf ("%02x", md5buffer[i]);
+ putchar ('\n');
+ } else if (!fail) {
size_t i;
/* Output a leading backslash if the file name contains
a newline or backslash. */
size_t i;
/* Output a leading backslash if the file name contains
a newline or backslash. */
@@
-940,11
+943,11
@@
int md5sum_main(int argc,
}
if (fclose (stdout) == EOF) {
}
if (fclose (stdout) == EOF) {
- error_msg_and_die("write error
\n
");
+ error_msg_and_die("write error");
}
if (have_read_stdin && fclose (stdin) == EOF) {
}
if (have_read_stdin && fclose (stdin) == EOF) {
- error_msg_and_die("standard input
\n
");
+ error_msg_and_die("standard input");
}
if (err == 0)
}
if (err == 0)