Commit Graph

32 Commits

Author SHA1 Message Date
Hu Tao
838f669682 Add vim configuration that makes vim auto-indent code 2011-03-17 17:08:51 -06:00
Eric Blake
1000d9c2b0 maint: document dislike of mismatched if/else bracing
* docs/hacking.html.in (Curly braces): Tighten recommendations to
disallow if (cond) one-line; else { block; }.
* HACKING: Regenerate.
Suggested by Daniel P. Berrange.
2011-01-05 11:05:28 -07:00
Jiri Denemark
5414d6b6ae doc: Fix spelling of virBufferVSprintf 2010-11-25 18:14:58 +01:00
Eric Blake
149c492137 libvirtd: fix bug when shrinking number of clients
* daemon/libvirtd.c (qemudRunLoop): Pass allocation size, not
current count, to VIR_SHRINK_N.
* docs/hacking.html.in: Update doc example.
* HACKING: Regenerate.
2010-11-23 08:43:00 -07:00
Eric Blake
269d3b72f6 memory: make it easier to avoid quadratic scaling of arrays
* src/util/memory.h (VIR_RESIZE_N): New macro.
* src/util/memory.c (virResizeN): New function.
* src/libvirt_private.syms: Export new helper.
* docs/hacking.html.in: Document it.
* HACKING: Regenerate.
2010-11-18 12:17:49 -07:00
Eric Blake
5a0beacc12 memory: make it safer to expand arrays
* src/util/memory.h (VIR_REALLOC_N): Update docs.
(VIR_EXPAND_N, VIR_SHRINK_N): New macros.
(virAlloc, virAllocN, virReallocN, virAllocVar, virFree): Add some
gcc attributes.
* src/util/memory.c (virExpandN, virShrinkN): New functions.
(virReallocN): Update docs.
* src/libvirt_private.syms: Export new helpers.
* docs/hacking.html.in: Prefer newer interfaces over
VIR_REALLOC_N, since uninitialized memory can bite us.
* HACKING: Regenerate.
2010-11-18 12:11:43 -07:00
Eric Blake
e8aba782e7 maint: avoid remaining sprintf uses
* cfg.mk (sc_prohibit_sprintf): New rule.
(sc_prohibit_asprintf): Avoid false positives.
* docs/hacking.html.in (Printf-style functions): Document the
policy.
* HACKING: Regenerate.
* .x-sc_prohibit_sprintf: New exemptions.
* Makefile.am (syntax_check_exceptions): Ship new file.
* src/vbox/vbox_tmpl.c (vboxStartMachine, vboxAttachUSB): Use
virAsprintf instead.
* src/uml/uml_driver.c (umlOpenMonitor): Use snprintf instead.
* tools/virsh.c (cmdDetachInterface): Likewise.
* src/security/security_selinux.c (SELinuxGenSecurityLabel):
Likewise.
* src/openvz/openvz_driver.c (openvzDomainDefineCmd): Likewise,
and ensure large enough buffer.
2010-11-17 10:13:12 -07:00
Stefan Berger
7b7cb1ecc9 deprecate fclose() and introduce VIR_{FORCE_}FCLOSE()
Similarly to deprecating close(), I am now deprecating fclose() and
introduce VIR_FORCE_FCLOSE() and VIR_FCLOSE(). Also, fdopen() is replaced with
VIR_FDOPEN().

Most of the files are opened in read-only mode, so usage of
VIR_FORCE_CLOSE() seemed appropriate. Others that are opened in write
mode already had the fclose()<  0 check and I converted those to
VIR_FCLOSE()<  0.

I did not find occurrences of possible double-closed files on the way.
2010-11-16 21:13:29 -05:00
Matthias Bolte
34ed4e9809 Generate HACKING from docs/hacking.html.in 2010-11-12 19:47:20 +01:00
Stefan Berger
f04de501bc Introduce VIR_CLOSE to be used rather than close()
Since bugs due to double-closed file descriptors are difficult to track down in a multi-threaded system, I am introducing the VIR_CLOSE(fd) macro to help avoid mistakes here.

There are lots of places where close() is being used. In this patch I am only cleaning up usage of close() in src/conf where the problems were.

I also dare to declare close() as being deprecated in libvirt code base (HACKING).
2010-10-19 10:23:51 -04:00
Jim Meyering
44258473b8 docs: hacking: explain why using curly braces well is important
* docs/hacking.html.in: Use the "curly braces" section from coreutils'
HACKING, adapting for libvirt's different formatting style.
* HACKING: Sync from the above, still mostly manually.
2010-05-04 15:41:21 +02:00
Jim Meyering
d1c754168a doc: fix typos in hacking.html.in; mark HACKING as read-only
* HACKING: Mark as read-only.  Soon we'll generate it from...
* docs/hacking.html.in: ... this file.  More typo fixes.
2010-03-09 18:18:20 +01:00
Jim Meyering
2a13ecc9be doc: fix more typos in HACKING
* HACKING: More spelling/typo fixes.
2010-03-09 17:26:24 +01:00
Eric Blake
095375925e hacking: add a section on preprocessor conventions
* doc/hacking.html.in (preprocessor): New section to document
recently-discussed style issues.

Signed-off-by: Eric Blake <eblake@redhat.com>
2010-03-09 17:07:15 +01:00
Eric Blake
0be3783316 hacking: fix typos
* docs/hacking.html.in (committers): Fix spelling and grammar.
2010-03-09 17:01:20 +01:00
Matthias Bolte
8ce5e2c1ab Remove conn parameter from virReportOOMError 2010-02-09 01:04:54 +01:00
Matthias Bolte
b1cd474c77 docs: Refer to virReportOOMError in the HACKING file
Instead of refering to __virRaiseError(VIR_ERROR_NO_MEMORY).
2010-02-04 19:09:28 +01:00
Eric Blake
3fc974209a maint: fix spelling error in hacking
* HACKING: STRCASEEQ is case insensitive.
* docs/hacking.html.in: Likewise.
2010-01-29 21:48:39 +01:00
Matthias Bolte
728e9229b1 Replace old CVS references with GIT 2010-01-08 18:08:22 +01:00
Matthias Bolte
1b9d074493 Add virBufferFreeAndReset() and replace free()
Replace free(virBufferContentAndReset()) with virBufferFreeAndReset().
Update documentation and replace all remaining calls to free() with
calls to VIR_FREE(). Also add missing calls to virBufferFreeAndReset()
and virReportOOMError() in OOM error cases.
2009-12-10 00:00:50 +01:00
Cole Robinson
9710856b33 tests: Centralize VIR_TEST_DEBUG lookup, and document it
Provide a simple interface for other tests to lookup the testDebug variable.
Also remove a redundant error message in interface tests.

If anyone feels inclined to change this env variable to match the existing
LIBVIRT_* format, it should now be easier to do so.
2009-10-20 14:17:34 -04:00
Chris Lalancette
03d777f345 Introduce virStrncpy.
Add the virStrncpy function, which takes a dst string, source string,
the number of bytes to copy and the number of bytes available in the
dest string.  If the source string is too large to fit into the
destination string, including the \0 byte, then no data is copied and
the function returns NULL.  Otherwise, this function copies n bytes
from source into dst, including the \0, and returns a pointer to the
dst string.  This function is intended to replace all unsafe uses
of strncpy in the code base, since strncpy does *not* guarantee that
the buffer terminates with a \0.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-22 20:10:00 +02:00
Daniel P. Berrange
899ae0d2b5 Fix misc Win32 compile warnings
GCC >= 4.4 assumes the 'printf' attribute refers to the native
runtime libraries format specifiers. Thanks to gnulib, libvirt
has GNU format specifiers everywhere.  This means we need to
use 'gnu_printf' with GCC >= 4.4 to get correct compiler
checking of printf format specifiers.

* HACKING: Document new rules for ATTRIBUTE_FMT_PRINTF
* autobuild.sh, mingw32-libvirt.spec.in: Disable OpenNebula
  driver on mingw32 builds
* qemud/dispatch.h, qemud/qemu.h, src/buf.h src/internal.h,
  src/logging.h, src/security.h, src/sexpr.h, src/util.h,
  src/virterror_internal.h, src/xend_internal.c: Change
  over to ATTRIBUTE_FMT_PRINTF.
* src/virsh.c: Disable 'cd' and 'pwd' commands on Win32
  since they don't compile
* src/threads-win32.c: Add missing return value check
2009-07-23 16:07:32 +01:00
Jim Meyering
17bfd657b7 * HACKING: Clarify "bool" vs. XDR/wire-format. 2009-01-13 10:45:41 +00:00
Jim Meyering
33a7dc93d8 HACKING: mention bool and other scalar types, const-correctness 2009-01-05 08:12:11 +00:00
Jim Meyering
e4c7e12300 let gcc's -Wformat do its job; avoid "make syntax-check" failure
* src/util.c (virAsprintf): Remove trailing space.
* src/util.h (virAsprintf): Use ATTRIBUTE_FORMAT.
* HACKING (Printf-style functions): New section.
2008-12-17 17:22:43 +00:00
Daniel Veillard
85432b0bd0 Document somme commit rules, and add application monitoring links to docs
* HACKING: update with some rules for commiters
* docs/apps.html docs/apps.html.in: add a section on monitoring
  support
daniel
2008-10-21 14:26:59 +00:00
Richard W.M. Jones
ccb516144e Link to "how to contribute to open source"
* HACKING: Link to external document which describes how to
	  contribute to open source projects.
2008-08-01 11:25:22 +00:00
Richard W.M. Jones
4a9ebf7da7 General tips for contributing patches
* HACKING: Added section "general tips for contributing patches"
	to this file.
2008-06-02 11:53:23 +00:00
Richard W.M. Jones
1d8d4f86b6 Standardize use of header files, making internal.h primary.
* qemud/internal.h, qemud/qemud.h: Rename this file so it
	doesn't conflict with src/internal.h.
	* HACKING: Document how header files should be used.
	* qemud/Makefile.am: Add src/ directory to includes.
	* qemud/event.c, qemud/mdns.c, qemud/qemud.c, qemud/remote.c,
	qemud/remote_protocol.c, qemud/remote_protocol.h,
	qemud/remote_protocol.x, src/buf.c, src/libvirt.c,
	src/nodeinfo.c, src/qemu_conf.c, src/qemu_driver.c,
	src/stats_linux.c, src/storage_backend.c, src/storage_backend_fs.c,
	src/storage_backend_iscsi.c, src/storage_backend_logical.c,
	src/storage_conf.c, src/storage_driver.c, src/util.c,
	src/util.h, src/virsh.c, src/virterror.c, src/xend_internal.c,
	src/xml.c, tests/reconnect.c, tests/xmlrpctest.c,
	tests/qparamtest.c: Standardize	use of header files.
	* docs/*, po/*: Rebuild docs.
2008-05-23 08:24:41 +00:00
Daniel P. Berrange
d9691ab277 Added some notes about libvirt string/memory/buffer functions 2008-05-08 14:49:53 +00:00
Jim Meyering
fa8ddb744d HACKING: New file: begin to describe contributor/coding guidelines 2008-04-10 16:56:44 +00:00