~serge-hallyn/ubuntu/oneiric/libvirt/fix-shutdown

« back to all changes in this revision

Viewing changes to src/util/buf.c

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2010-11-02 16:26:51 UTC
  • mfrom: (1.2.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20101102162651-aq8tnbz58mdf01bf
Tags: 0.8.5-0ubuntu1
* New upstream release.
* Removed a slew of patches which have been
  applied upstream since 0.8.3.
  - 9012-apparmor-extra-tests.patch
  - 9013-apparmor-chardev.patch
  - 9015-Add-ubd-to-the-list-of-disk-prefixes.patch
  - 9016-Close-fd-s-of-persistent-tap-devices.patch
  - 9017-Make-sure-all-command-line-arguments-get-passed-to-U.patch
  - 9018-Make-umlConnectTapDevice-ask-brAddTap-for-a-persiste.patch
  - 9019-uml-fix-logic-bug-in-checking-reply-length.patch
  - 9021-Allow-chardev-of-type-file-for-UML-domains.patch
  - 9022-Rename-qemudShrinkDisks-to-virDomainDiskRemove-and-m.patch
  - 9023-Support-virDomainAttachDevice-and-virDomainDetachDev.patch
  - 9024-Explicitly-pass-uml_dir-argument-to-user-mode-linux.patch
  - 9025-Add-nwfilter-support-to-UML-driver.patch
  - 9026-Rebuild-network-filter-for-UML-guests-on-updates.patch
  - 9027-Make-newfilter-xml-transformations-endian-safe.patch
  - 9028-lp628055.patch
* Updated 9002-better_default_uri_virsh.patch to use vshStrdup,
  as now required in that file.  (use of strdup now causes compilation
  to fail)
* Removed 9008-run-as-root-by-default.patch, which has not been
  applied for awhile now, with no ill effects.
* Simple refresh of:
  - 0001-remove-RHism.diff.patch
  - 0003-allow-libvirt-group-to-access-the-socket.patch
  - 0004-fix-Debian-specific-path-to-hvm-loader.patch
  - 0006-patch-qemuMonitorTextGetMigrationStatus-to-intercept.patch
  - 9000-delayed_iff_up_bridge.patch
  - 9001-dont_clobber_existing_bridges.patch
  - 9003-better-default-arch.patch
  - 9004-libvirtd-group-name.patch
  - 9005-increase-unix-socket-timeout.patch
  - 9006-default-config-test-case.patch
  - 9009-autodetect-nc-params.patch
  - 9010-dont-disable-ipv6.patch
  - 9011-move-ebtables-script.patch
  - 9014-skip-nodeinfotest.patch
  - 9020-lp545795.patch
* Create a patch to include stdint.h so lxc_container.h, which
  #includes linux/fs.h, doesn't trip up on undefined uint64_t.

Show diffs side-by-side

added added

removed removed

Lines of Context:
224
224
virBufferVSprintf(const virBufferPtr buf, const char *format, ...)
225
225
{
226
226
    int size, count, grow_size;
227
 
    va_list locarg, argptr;
 
227
    va_list argptr;
228
228
 
229
229
    if ((format == NULL) || (buf == NULL))
230
230
        return;
236
236
        virBufferGrow(buf, 100) < 0)
237
237
        return;
238
238
 
239
 
    size = buf->size - buf->use - 1;
240
239
    va_start(argptr, format);
241
 
    va_copy(locarg, argptr);
242
 
    while (((count = vsnprintf(&buf->content[buf->use], size, format,
243
 
                               locarg)) < 0) || (count >= size - 1)) {
 
240
 
 
241
    size = buf->size - buf->use;
 
242
    if ((count = vsnprintf(&buf->content[buf->use],
 
243
                           size, format, argptr)) < 0) {
 
244
        buf->error = 1;
 
245
        goto err;
 
246
    }
 
247
 
 
248
    /* Grow buffer if necessary and retry */
 
249
    if (count >= size) {
244
250
        buf->content[buf->use] = 0;
245
 
        va_end(locarg);
 
251
        va_end(argptr);
 
252
        va_start(argptr, format);
246
253
 
247
 
        grow_size = (count > 1000) ? count : 1000;
 
254
        grow_size = (count + 1 > 1000) ? count + 1 : 1000;
248
255
        if (virBufferGrow(buf, grow_size) < 0) {
249
 
            va_end(argptr);
250
 
            return;
 
256
            goto err;
251
257
        }
252
258
 
253
 
        size = buf->size - buf->use - 1;
254
 
        va_copy(locarg, argptr);
 
259
        size = buf->size - buf->use;
 
260
        if ((count = vsnprintf(&buf->content[buf->use],
 
261
                               size, format, argptr)) < 0) {
 
262
            buf->error = 1;
 
263
            goto err;
 
264
        }
255
265
    }
 
266
    buf->use += count;
 
267
 
 
268
err:
256
269
    va_end(argptr);
257
 
    va_end(locarg);
258
 
    buf->use += count;
259
 
    buf->content[buf->use] = '\0';
 
270
    return;
260
271
}
261
272
 
262
273
/**
336
347
 
337
348
    if ((buf->use >= buf->size) &&
338
349
        virBufferGrow(buf, 100) < 0) {
339
 
        VIR_FREE(escaped);
340
 
        return;
341
 
    }
342
 
 
343
 
    size = buf->size - buf->use - 1;
344
 
    while (((count = snprintf(&buf->content[buf->use], size, format,
345
 
                              (char *)escaped)) < 0) || (count >= size - 1)) {
 
350
        goto err;
 
351
    }
 
352
 
 
353
    size = buf->size - buf->use;
 
354
    if ((count = snprintf(&buf->content[buf->use], size,
 
355
                          format, (char *)escaped)) < 0) {
 
356
            buf->error = 1;
 
357
        goto err;
 
358
    }
 
359
 
 
360
    /* Grow buffer if necessary and retry */
 
361
    if (count >= size) {
346
362
        buf->content[buf->use] = 0;
347
 
        grow_size = (count > 1000) ? count : 1000;
 
363
        grow_size = (count + 1 > 1000) ? count + 1 : 1000;
348
364
        if (virBufferGrow(buf, grow_size) < 0) {
349
 
            VIR_FREE(escaped);
350
 
            return;
351
 
        }
352
 
        size = buf->size - buf->use - 1;
 
365
            goto err;
 
366
        }
 
367
        size = buf->size - buf->use;
 
368
 
 
369
        if ((count = snprintf(&buf->content[buf->use], size,
 
370
                              format, (char *)escaped)) < 0) {
 
371
            buf->error = 1;
 
372
            goto err;
 
373
        }
353
374
    }
354
375
    buf->use += count;
355
 
    buf->content[buf->use] = '\0';
 
376
 
 
377
err:
356
378
    VIR_FREE(escaped);
357
379
}
358
380