Skip to content

Commit

Permalink
qga: Add spaces around operator
Browse files Browse the repository at this point in the history
Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: AlexChen <alex.chen@huawei.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
*fix 80+ char violation while we're here
*fix w32 build breakage from changing INVALID_SET_FILE_POINTER
 definition from a cast to a subtraction
Signed-off-by: Michael Roth <michael.roth@amd.com>
  • Loading branch information
AlexChen authored and mdroth committed Mar 17, 2021
1 parent 27e7de3 commit 0697e9e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
7 changes: 4 additions & 3 deletions qga/channel-win32.c
Expand Up @@ -292,9 +292,9 @@ static gboolean ga_channel_open(GAChannel *c, GAChannelMethod method,
return false;
}

if (method == GA_CHANNEL_ISA_SERIAL){
if (method == GA_CHANNEL_ISA_SERIAL) {
snprintf(newpath, sizeof(newpath), "\\\\.\\%s", path);
}else {
} else {
g_strlcpy(newpath, path, sizeof(newpath));
}

Expand All @@ -307,7 +307,8 @@ static gboolean ga_channel_open(GAChannel *c, GAChannelMethod method,
return false;
}

if (method == GA_CHANNEL_ISA_SERIAL && !SetCommTimeouts(c->handle,&comTimeOut)) {
if (method == GA_CHANNEL_ISA_SERIAL
&& !SetCommTimeouts(c->handle, &comTimeOut)) {
g_autofree gchar *emsg = g_win32_error_message(GetLastError());
g_critical("error setting timeout for com port: %s", emsg);
CloseHandle(c->handle);
Expand Down
4 changes: 2 additions & 2 deletions qga/commands-posix.c
Expand Up @@ -110,7 +110,7 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
reopen_fd_to_null(2);

execle("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0",
"hypervisor initiated shutdown", (char*)NULL, environ);
"hypervisor initiated shutdown", (char *)NULL, environ);
_exit(EXIT_FAILURE);
} else if (pid < 0) {
error_setg_errno(errp, errno, "failed to create child process");
Expand Down Expand Up @@ -479,7 +479,7 @@ GuestFileRead *guest_file_read_unsafe(GuestFileHandle *gfh,
gfh->state = RW_STATE_NEW;
}

buf = g_malloc0(count+1);
buf = g_malloc0(count + 1);
read_count = fread(buf, 1, count, fh);
if (ferror(fh)) {
error_setg_errno(errp, errno, "failed to read file");
Expand Down
22 changes: 11 additions & 11 deletions qga/commands-win32.c
Expand Up @@ -110,15 +110,15 @@ static OpenFlags guest_file_open_modes[] = {
{"w", GENERIC_WRITE, CREATE_ALWAYS},
{"wb", GENERIC_WRITE, CREATE_ALWAYS},
{"a", FILE_GENERIC_APPEND, OPEN_ALWAYS },
{"r+", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
{"rb+", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
{"r+b", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
{"w+", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
{"wb+", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
{"w+b", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
{"a+", FILE_GENERIC_APPEND|GENERIC_READ, OPEN_ALWAYS },
{"ab+", FILE_GENERIC_APPEND|GENERIC_READ, OPEN_ALWAYS },
{"a+b", FILE_GENERIC_APPEND|GENERIC_READ, OPEN_ALWAYS }
{"r+", GENERIC_WRITE | GENERIC_READ, OPEN_EXISTING},
{"rb+", GENERIC_WRITE | GENERIC_READ, OPEN_EXISTING},
{"r+b", GENERIC_WRITE | GENERIC_READ, OPEN_EXISTING},
{"w+", GENERIC_WRITE | GENERIC_READ, CREATE_ALWAYS},
{"wb+", GENERIC_WRITE | GENERIC_READ, CREATE_ALWAYS},
{"w+b", GENERIC_WRITE | GENERIC_READ, CREATE_ALWAYS},
{"a+", FILE_GENERIC_APPEND | GENERIC_READ, OPEN_ALWAYS },
{"ab+", FILE_GENERIC_APPEND | GENERIC_READ, OPEN_ALWAYS },
{"a+b", FILE_GENERIC_APPEND | GENERIC_READ, OPEN_ALWAYS }
};

#define debug_error(msg) do { \
Expand Down Expand Up @@ -280,7 +280,7 @@ static void acquire_privilege(const char *name, Error **errp)
Error *local_err = NULL;

if (OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token))
{
if (!LookupPrivilegeValue(NULL, name, &priv.Privileges[0].Luid)) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
Expand Down Expand Up @@ -1116,7 +1116,7 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp)

len = strlen(mnt_point);
mnt_point[len] = '\\';
mnt_point[len+1] = 0;
mnt_point[len + 1] = 0;

if (!GetVolumeInformationByHandleW(hLocalDiskHandle, vol_info,
sizeof(vol_info), NULL, NULL, NULL,
Expand Down
4 changes: 2 additions & 2 deletions qga/commands.c
Expand Up @@ -22,9 +22,9 @@
#include "commands-common.h"

/* Maximum captured guest-exec out_data/err_data - 16MB */
#define GUEST_EXEC_MAX_OUTPUT (16*1024*1024)
#define GUEST_EXEC_MAX_OUTPUT (16 * 1024 * 1024)
/* Allocation and I/O buffer for reading guest-exec out_data/err_data - 4KB */
#define GUEST_EXEC_IO_SIZE (4*1024)
#define GUEST_EXEC_IO_SIZE (4 * 1024)
/*
* Maximum file size to read - 48MB
*
Expand Down
4 changes: 2 additions & 2 deletions qga/main.c
Expand Up @@ -586,7 +586,7 @@ static void process_event(void *opaque, QObject *obj, Error *err)
static gboolean channel_event_cb(GIOCondition condition, gpointer data)
{
GAState *s = data;
gchar buf[QGA_READ_COUNT_DEFAULT+1];
gchar buf[QGA_READ_COUNT_DEFAULT + 1];
gsize count;
GIOStatus status = ga_channel_read(s->channel, buf, QGA_READ_COUNT_DEFAULT, &count);
switch (status) {
Expand All @@ -610,7 +610,7 @@ static gboolean channel_event_cb(GIOCondition condition, gpointer data)
* host-side chardev. sleep a bit to mitigate this
*/
if (s->virtio) {
usleep(100*1000);
usleep(100 * 1000);
}
return true;
default:
Expand Down

0 comments on commit 0697e9e

Please sign in to comment.