Deleted Added
full compact
ebuf.c (225787) ebuf.c (229945)
1/*-
2 * Copyright (c) 2009-2010 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Pawel Jakub Dawidek under sponsorship from
6 * the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009-2010 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Pawel Jakub Dawidek under sponsorship from
6 * the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sbin/hastd/ebuf.c 225787 2011-09-27 08:50:37Z pjd $");
31__FBSDID("$FreeBSD: head/sbin/hastd/ebuf.c 229945 2012-01-10 22:39:07Z pjd $");
32
33#include <sys/param.h>
34
35#include <errno.h>
36#include <stdbool.h>
37#include <stdint.h>
38#include <strings.h>
39#include <unistd.h>

--- 71 unchanged lines hidden (view full) ---

111
112 PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC);
113
114 if (size > (size_t)(eb->eb_used - eb->eb_start)) {
115 /*
116 * We can't add more entries at the front, so we have to extend
117 * our buffer.
118 */
32
33#include <sys/param.h>
34
35#include <errno.h>
36#include <stdbool.h>
37#include <stdint.h>
38#include <strings.h>
39#include <unistd.h>

--- 71 unchanged lines hidden (view full) ---

111
112 PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC);
113
114 if (size > (size_t)(eb->eb_used - eb->eb_start)) {
115 /*
116 * We can't add more entries at the front, so we have to extend
117 * our buffer.
118 */
119 if (ebuf_head_extend(eb, size) < 0)
119 if (ebuf_head_extend(eb, size) == -1)
120 return (-1);
121 }
122 PJDLOG_ASSERT(size <= (size_t)(eb->eb_used - eb->eb_start));
123
124 eb->eb_size += size;
125 eb->eb_used -= size;
126 /*
127 * If data is NULL the caller just wants to reserve place.

--- 10 unchanged lines hidden (view full) ---

138
139 PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC);
140
141 if (size > (size_t)(eb->eb_end - (eb->eb_used + eb->eb_size))) {
142 /*
143 * We can't add more entries at the back, so we have to extend
144 * our buffer.
145 */
120 return (-1);
121 }
122 PJDLOG_ASSERT(size <= (size_t)(eb->eb_used - eb->eb_start));
123
124 eb->eb_size += size;
125 eb->eb_used -= size;
126 /*
127 * If data is NULL the caller just wants to reserve place.

--- 10 unchanged lines hidden (view full) ---

138
139 PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC);
140
141 if (size > (size_t)(eb->eb_end - (eb->eb_used + eb->eb_size))) {
142 /*
143 * We can't add more entries at the back, so we have to extend
144 * our buffer.
145 */
146 if (ebuf_tail_extend(eb, size) < 0)
146 if (ebuf_tail_extend(eb, size) == -1)
147 return (-1);
148 }
149 PJDLOG_ASSERT(size <=
150 (size_t)(eb->eb_end - (eb->eb_used + eb->eb_size)));
151
152 /*
153 * If data is NULL the caller just wants to reserve space.
154 */

--- 105 unchanged lines hidden ---
147 return (-1);
148 }
149 PJDLOG_ASSERT(size <=
150 (size_t)(eb->eb_end - (eb->eb_used + eb->eb_size)));
151
152 /*
153 * If data is NULL the caller just wants to reserve space.
154 */

--- 105 unchanged lines hidden ---