Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
6c30b539
Commit
6c30b539
authored
Mar 22, 2011
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crcsync: avoid arithmetic on void pointers
parent
061e359b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
ccan/crcsync/crcsync.c
ccan/crcsync/crcsync.c
+6
-4
No files found.
ccan/crcsync/crcsync.c
View file @
6c30b539
...
...
@@ -166,7 +166,7 @@ size_t crc_read_block(struct crc_context *ctx, long *result,
/* old is the trailing edge of the checksum window. */
if
(
buffer_size
(
ctx
)
>=
ctx
->
block_size
)
old
=
ctx
->
buffer
+
ctx
->
buffer_start
;
old
=
(
uint8_t
*
)
ctx
->
buffer
+
ctx
->
buffer_start
;
else
old
=
NULL
;
...
...
@@ -187,7 +187,7 @@ size_t crc_read_block(struct crc_context *ctx, long *result,
ctx
->
uncrc_tab
);
old
++
;
/* End of stored buffer? Start on data they gave us. */
if
(
old
==
ctx
->
buffer
+
ctx
->
buffer_end
)
if
(
old
==
(
uint8_t
*
)
ctx
->
buffer
+
ctx
->
buffer_end
)
old
=
buf
;
}
else
{
ctx
->
running_crc
=
crc_add_byte
(
ctx
->
running_crc
,
*
p
);
...
...
@@ -242,14 +242,16 @@ size_t crc_read_block(struct crc_context *ctx, long *result,
/* Move down old data if we don't have room. */
if
(
ctx
->
buffer_end
+
len
>
ctx
->
block_size
)
{
memmove
(
ctx
->
buffer
,
ctx
->
buffer
+
ctx
->
buffer_start
,
memmove
(
ctx
->
buffer
,
(
uint8_t
*
)
ctx
->
buffer
+
ctx
->
buffer_start
,
buffer_size
(
ctx
));
ctx
->
buffer_end
-=
ctx
->
buffer_start
;
ctx
->
buffer_start
=
0
;
}
/* Copy len bytes from tail of buffer. */
memcpy
(
ctx
->
buffer
+
ctx
->
buffer_end
,
buf
+
buflen
-
len
,
len
);
memcpy
((
uint8_t
*
)
ctx
->
buffer
+
ctx
->
buffer_end
,
(
const
uint8_t
*
)
buf
+
buflen
-
len
,
len
);
ctx
->
buffer_end
+=
len
;
assert
(
buffer_size
(
ctx
)
<=
ctx
->
block_size
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment