git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fish.c: don't perform arithmetic on void* pointers
[libguestfs.git]
/
fish
/
fish.c
diff --git
a/fish/fish.c
b/fish/fish.c
index
f31f4ad
..
3acd450
100644
(file)
--- a/
fish/fish.c
+++ b/
fish/fish.c
@@
-267,7
+267,7
@@
main (int argc, char *argv[])
*p = '\0';
mp->mountpoint = p+1;
} else
*p = '\0';
mp->mountpoint = p+1;
} else
- mp->mountpoint =
"/"
;
+ mp->mountpoint =
bad_cast ("/")
;
mp->device = optarg;
mp->next = mps;
mps = mp;
mp->device = optarg;
mp->next = mps;
mps = mp;
@@
-517,7
+517,7
@@
script (int prompt)
char *cmd;
char *p, *pend;
char *argv[64];
char *cmd;
char *p, *pend;
char *argv[64];
- int
i,
len;
+ int len;
int global_exit_on_error = !prompt;
int tilde_candidate;
int global_exit_on_error = !prompt;
int tilde_candidate;
@@
-581,7
+581,7
@@
script (int prompt)
if (len == 0) continue;
cmd = buf;
if (len == 0) continue;
cmd = buf;
- i = 0;
+
unsigned int
i = 0;
if (buf[len] == '\0') {
argv[0] = NULL;
goto got_command;
if (buf[len] == '\0') {
argv[0] = NULL;
goto got_command;
@@
-750,8
+750,14
@@
issue_command (const char *cmd, char *argv[], const char *pipecmd)
if (pipecmd) {
int fd[2];
if (pipecmd) {
int fd[2];
- fflush (stdout);
- pipe (fd);
+ if (fflush (stdout) == EOF) {
+ perror ("failed to flush standard output");
+ return -1;
+ }
+ if (pipe (fd) < 0) {
+ perror ("pipe failed");
+ return -1;
+ }
pid = fork ();
if (pid == -1) {
perror ("fork");
pid = fork ();
if (pid == -1) {
perror ("fork");
@@
-760,7
+766,10
@@
issue_command (const char *cmd, char *argv[], const char *pipecmd)
if (pid == 0) { /* Child process. */
close (fd[1]);
if (pid == 0) { /* Child process. */
close (fd[1]);
- dup2 (fd[0], 0);
+ if (dup2 (fd[0], 0) < 0) {
+ perror ("dup2 of stdin failed");
+ _exit (1);
+ }
r = system (pipecmd);
if (r == -1) {
r = system (pipecmd);
if (r == -1) {
@@
-770,9
+779,16
@@
issue_command (const char *cmd, char *argv[], const char *pipecmd)
_exit (WEXITSTATUS (r));
}
_exit (WEXITSTATUS (r));
}
- stdout_saved_fd = dup (1);
+ if ((stdout_saved_fd = dup (1)) < 0) {
+ perror ("failed to dup stdout");
+ return -1;
+ }
close (fd[0]);
close (fd[0]);
- dup2 (fd[1], 1);
+ if (dup2 (fd[1], 1) < 0) {
+ perror ("failed to dup stdout");
+ close (stdout_saved_fd);
+ return -1;
+ }
close (fd[1]);
}
close (fd[1]);
}
@@
-823,13
+839,22
@@
issue_command (const char *cmd, char *argv[], const char *pipecmd)
/* Always flush stdout after every command, so that messages, results
* etc appear immediately.
*/
/* Always flush stdout after every command, so that messages, results
* etc appear immediately.
*/
- fflush (stdout);
+ if (fflush (stdout) == EOF) {
+ perror ("failed to flush standard output");
+ return -1;
+ }
if (pipecmd) {
close (1);
if (pipecmd) {
close (1);
- dup2 (stdout_saved_fd, 1);
+ if (dup2 (stdout_saved_fd, 1) < 0) {
+ perror ("failed to dup2 standard output");
+ r = -1;
+ }
close (stdout_saved_fd);
close (stdout_saved_fd);
- waitpid (pid, NULL, 0);
+ if (waitpid (pid, NULL, 0) < 0) {
+ perror ("waiting for command to complete");
+ r = -1;
+ }
}
return r;
}
return r;
@@
-974,7
+999,7
@@
free_strings (char **argv)
}
int
}
int
-count_strings (char *
const * const
argv)
+count_strings (char *
const *
argv)
{
int c;
{
int c;
@@
-984,7
+1009,7
@@
count_strings (char * const * const argv)
}
void
}
void
-print_strings (char *
const * const
argv)
+print_strings (char *
const *
argv)
{
int argc;
{
int argc;
@@
-993,7
+1018,7
@@
print_strings (char * const * const argv)
}
void
}
void
-print_table (char *
const * const
argv)
+print_table (char *
const *
argv)
{
int i;
{
int i;
@@
-1092,9
+1117,10
@@
add_history_line (const char *line)
}
int
}
int
-xwrite (int fd, const void *buf, size_t len)
+xwrite (int fd, const void *
v_
buf, size_t len)
{
int r;
{
int r;
+ const char *buf = v_buf;
while (len > 0) {
r = write (fd, buf, len);
while (len > 0) {
r = write (fd, buf, len);