View | Details | Raw Unified | Return to bug 2769 | Differences between
and this patch

Collapse All | Expand All

(-)a/openbsd-compat/fmt_scaled.c (-2 / +3 lines)
Lines 42-47 Link Here
42
42
43
#ifndef HAVE_FMT_SCALED
43
#ifndef HAVE_FMT_SCALED
44
44
45
#include <assert.h>
45
#include <stdio.h>
46
#include <stdio.h>
46
#include <stdlib.h>
47
#include <stdlib.h>
47
#include <errno.h>
48
#include <errno.h>
Lines 246-258 fmt_scaled(long long number, char *result) Link Here
246
247
247
	fract = (10 * fract + 512) / 1024;
248
	fract = (10 * fract + 512) / 1024;
248
	/* if the result would be >= 10, round main number */
249
	/* if the result would be >= 10, round main number */
249
	if (fract == 10) {
250
	if (fract >= 10) {
250
		if (number >= 0)
251
		if (number >= 0)
251
			number++;
252
			number++;
252
		else
253
		else
253
			number--;
254
			number--;
254
		fract = 0;
255
		fract = 0;
255
	}
256
	}
257
	assert(fract >= 0);
256
258
257
	if (number == 0)
259
	if (number == 0)
258
		strlcpy(result, "0B", FMT_SCALED_STRSIZE);
260
		strlcpy(result, "0B", FMT_SCALED_STRSIZE);
259
- 

Return to bug 2769