Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-pul…
Browse files Browse the repository at this point in the history
…l-request' into staging

Pull request trivial branch 2019-05-03

# gpg: Signature made Fri 03 May 2019 12:26:34 BST
# gpg:                using RSA key F30C38BD3F2FBE3C
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [full]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full]
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier2/tags/trivial-branch-pull-request:
  sockets: avoid string truncation warnings when copying UNIX path
  hw/sparc/leon3: Allow load of uImage firmwares
  Makefile: Let the 'clean' rule remove qemu-ga.exe on Windows hosts
  net: Print output of "-net nic, model=help" to stdout instead of stderr
  Header cleanups
  Update configure
  configure: fix pam test warning
  qom: use object_new_with_type in object_new_with_propv
  doc: fix the configuration path
  CODING_STYLE: indent example code as all others
  CODING_STYLE: specify the indent rule for multiline code
  hw/net/pcnet: Use qemu_log_mask(GUEST_ERROR) instead of printf

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed May 9, 2019
2 parents c56247e + 2d2023c commit 68a7b97
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 25 deletions.
47 changes: 43 additions & 4 deletions CODING_STYLE
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,45 @@ Spaces of course are superior to tabs because:

Do not leave whitespace dangling off the ends of lines.

1.1 Multiline Indent

There are several places where indent is necessary:

- if/else
- while/for
- function definition & call

When breaking up a long line to fit within line width, we need a proper indent
for the following lines.

In case of if/else, while/for, align the secondary lines just after the
opening parenthesis of the first.

For example:

if (a == 1 &&
b == 2) {

while (a == 1 &&
b == 2) {

In case of function, there are several variants:

* 4 spaces indent from the beginning
* align the secondary lines just after the opening parenthesis of the
first

For example:

do_something(x, y,
z);

do_something(x, y,
z);

do_something(x, do_another(y,
z));

2. Line width

Lines should be 80 characters; try not to make them longer.
Expand Down Expand Up @@ -108,10 +147,10 @@ block to a separate function altogether.
When comparing a variable for (in)equality with a constant, list the
constant on the right, as in:

if (a == 1) {
/* Reads like: "If a equals 1" */
do_something();
}
if (a == 1) {
/* Reads like: "If a equals 1" */
do_something();
}

Rationale: Yoda conditions (as in 'if (1 == a)') are awkward to read.
Besides, good compilers already warn users when '==' is mis-typed as '=',
Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ clean:
! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
-exec rm {} +
rm -f $(edk2-decompressed)
rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga$(EXESUF) TAGS cscope.* *.pod *~ */*~
rm -f fsdev/*.pod scsi/*.pod
rm -f qemu-img-cmds.h
rm -f ui/shader/*-vert.h ui/shader/*-frag.h
Expand Down Expand Up @@ -899,11 +899,14 @@ ui/shader.o: $(SRC_PATH)/ui/shader.c \
MAKEINFO=makeinfo
MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
TEXI2PODFLAGS=$(MAKEINFOINCLUDES) "-DVERSION=$(VERSION)"
TEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" -DCONFDIR="$(qemu_confdir)"
TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)

docs/version.texi: $(SRC_PATH)/VERSION
$(call quiet-command,echo "@set VERSION $(VERSION)" > $@,"GEN","$@")
docs/version.texi: $(SRC_PATH)/VERSION config-host.mak
$(call quiet-command,(\
echo "@set VERSION $(VERSION)" && \
echo "@set CONFDIR $(qemu_confdir)" \
)> $@,"GEN","$@")

%.html: %.texi docs/version.texi
$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
Expand Down
5 changes: 2 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2937,9 +2937,9 @@ if test "$auth_pam" != "no"; then
int main(void) {
const char *service_name = "qemu";
const char *user = "frank";
const struct pam_conv *pam_conv = NULL;
const struct pam_conv pam_conv = { 0 };
pam_handle_t *pamh = NULL;
pam_start(service_name, user, pam_conv, &pamh);
pam_start(service_name, user, &pam_conv, &pamh);
return 0;
}
EOF
Expand Down Expand Up @@ -7882,7 +7882,6 @@ LINKS="$LINKS python"
for bios_file in \
$source_path/pc-bios/*.bin \
$source_path/pc-bios/*.lid \
$source_path/pc-bios/*.aml \
$source_path/pc-bios/*.rom \
$source_path/pc-bios/*.dtb \
$source_path/pc-bios/*.img \
Expand Down
4 changes: 3 additions & 1 deletion hw/net/pcnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
*/

#include "qemu/osdep.h"
#include "qemu/log.h"
#include "hw/qdev.h"
#include "net/net.h"
#include "net/eth.h"
Expand Down Expand Up @@ -1501,7 +1502,8 @@ static void pcnet_bcr_writew(PCNetState *s, uint32_t rap, uint32_t val)
val |= 0x0300;
break;
default:
printf("Bad SWSTYLE=0x%02x\n", val & 0xff);
qemu_log_mask(LOG_GUEST_ERROR, "pcnet: Bad SWSTYLE=0x%02x\n",
val & 0xff);
val = 0x0200;
break;
}
Expand Down
4 changes: 4 additions & 0 deletions hw/sparc/leon3.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ static void leon3_generic_hw_init(MachineState *machine)
kernel_size = load_elf(kernel_filename, NULL, NULL, NULL,
&entry, NULL, NULL,
1 /* big endian */, EM_SPARC, 0, 0);
if (kernel_size < 0) {
kernel_size = load_uimage(kernel_filename, NULL, &entry,
NULL, NULL, NULL);
}
if (kernel_size < 0) {
error_report("could not load kernel '%s'", kernel_filename);
exit(1);
Expand Down
3 changes: 0 additions & 3 deletions include/exec/cpu-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
#include "exec/hwaddr.h"
#endif

#include "qemu/bswap.h"
#include "qemu/queue.h"

/* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */
void qemu_init_cpu_list(void);
void cpu_list_lock(void);
Expand Down
7 changes: 4 additions & 3 deletions net/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,9 +837,10 @@ int qemu_show_nic_models(const char *arg, const char *const *models)
return 0;
}

fprintf(stderr, "qemu: Supported NIC models: ");
for (i = 0 ; models[i]; i++)
fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n');
printf("Supported NIC models:\n");
for (i = 0 ; models[i]; i++) {
printf("%s\n", models[i]);
}
return 1;
}

Expand Down
4 changes: 2 additions & 2 deletions qemu-ga.texi
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set user's password
@end itemize

qemu-ga will read a system configuration file on startup (located at
@file{/etc/qemu/qemu-ga.conf} by default), then parse remaining
@file{@value{CONFDIR}/qemu-ga.conf} by default), then parse remaining
configuration options on the command line. For the same key, the last
option wins, but the lists accumulate (see below for configuration
file format).
Expand Down Expand Up @@ -58,7 +58,7 @@ file format).
Enable fsfreeze hook. Accepts an optional argument that specifies
script to run on freeze/thaw. Script will be called with
'freeze'/'thaw' arguments accordingly (default is
@samp{/etc/qemu/fsfreeze-hook}). If using -F with an argument, do
@samp{@value{CONFDIR}/fsfreeze-hook}). If using -F with an argument, do
not follow -F with a space (for example:
@samp{-F/var/run/fsfreezehook.sh}).

Expand Down
2 changes: 1 addition & 1 deletion qom/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ Object *object_new_with_propv(const char *typename,
error_setg(errp, "object type '%s' is abstract", typename);
return NULL;
}
obj = object_new(typename);
obj = object_new_with_type(klass->type);

if (object_set_propv(obj, &local_err, vargs) < 0) {
goto error;
Expand Down
12 changes: 8 additions & 4 deletions util/qemu-sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr,
int sock, fd;
char *pathbuf = NULL;
const char *path;
size_t pathlen;

sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
Expand All @@ -845,7 +846,8 @@ static int unix_listen_saddr(UnixSocketAddress *saddr,
path = pathbuf = g_strdup_printf("%s/qemu-socket-XXXXXX", tmpdir);
}

if (strlen(path) > sizeof(un.sun_path)) {
pathlen = strlen(path);
if (pathlen > sizeof(un.sun_path)) {
error_setg(errp, "UNIX socket path '%s' is too long", path);
error_append_hint(errp, "Path must be less than %zu bytes\n",
sizeof(un.sun_path));
Expand Down Expand Up @@ -877,7 +879,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr,

memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
strncpy(un.sun_path, path, sizeof(un.sun_path));
memcpy(un.sun_path, path, pathlen);

if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {
error_setg_errno(errp, errno, "Failed to bind socket to %s", path);
Expand All @@ -901,6 +903,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp)
{
struct sockaddr_un un;
int sock, rc;
size_t pathlen;

if (saddr->path == NULL) {
error_setg(errp, "unix connect: no path specified");
Expand All @@ -913,7 +916,8 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp)
return -1;
}

if (strlen(saddr->path) > sizeof(un.sun_path)) {
pathlen = strlen(saddr->path);
if (pathlen > sizeof(un.sun_path)) {
error_setg(errp, "UNIX socket path '%s' is too long", saddr->path);
error_append_hint(errp, "Path must be less than %zu bytes\n",
sizeof(un.sun_path));
Expand All @@ -922,7 +926,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp)

memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
strncpy(un.sun_path, saddr->path, sizeof(un.sun_path));
memcpy(un.sun_path, saddr->path, pathlen);

/* connect to peer */
do {
Expand Down

0 comments on commit 68a7b97

Please sign in to comment.