Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/sctp_crc32.c
Show All 32 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_sctp.h" | #include "opt_sctp.h" | ||||
#ifdef SCTP | #ifdef SCTP | ||||
#include <sys/crc32.h> | |||||
delphij: Optional: It's probably reasonable to move this out of #ifdef block because it's required in… | |||||
Done Inline ActionsIs this order okay after moving these 2 include outside of #ifdef? ota_j.email.ne.jp: Is this order okay after moving these 2 include outside of #ifdef? | |||||
#include <netinet/sctp_os.h> | #include <netinet/sctp_os.h> | ||||
#include <netinet/sctp.h> | #include <netinet/sctp.h> | ||||
#include <netinet/sctp_crc32.h> | #include <netinet/sctp_crc32.h> | ||||
#include <netinet/sctp_pcb.h> | #include <netinet/sctp_pcb.h> | ||||
#else | #else | ||||
#include <sys/crc32.h> | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <netinet/sctp_crc32.h> | #include <netinet/sctp_crc32.h> | ||||
#endif | #endif | ||||
static uint32_t | static uint32_t | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | while (offset > 0) { | ||||
KASSERT(m != NULL, ("sctp_calculate_cksum, offset > length of mbuf chain")); | KASSERT(m != NULL, ("sctp_calculate_cksum, offset > length of mbuf chain")); | ||||
if (offset < (uint32_t)m->m_len) { | if (offset < (uint32_t)m->m_len) { | ||||
break; | break; | ||||
} | } | ||||
offset -= m->m_len; | offset -= m->m_len; | ||||
m = m->m_next; | m = m->m_next; | ||||
} | } | ||||
if (offset > 0) { | if (offset > 0) { | ||||
base = calculate_crc32c(base, | base = calculate_crc32c(base, | ||||
Done Inline ActionsThis is one of the call; so move it outside #ifdef. ota_j.email.ne.jp: This is one of the call; so move it outside #ifdef. | |||||
(unsigned char *)(m->m_data + offset), | (unsigned char *)(m->m_data + offset), | ||||
(unsigned int)(m->m_len - offset)); | (unsigned int)(m->m_len - offset)); | ||||
m = m->m_next; | m = m->m_next; | ||||
} | } | ||||
while (m != NULL) { | while (m != NULL) { | ||||
base = calculate_crc32c(base, | base = calculate_crc32c(base, | ||||
(unsigned char *)m->m_data, | (unsigned char *)m->m_data, | ||||
(unsigned int)m->m_len); | (unsigned int)m->m_len); | ||||
Show All 34 Lines |
Optional: It's probably reasonable to move this out of #ifdef block because it's required in both cases. (Note that netinet/sctp_pcb.h doesn't seem to need anything from sctp_crc32.h either, so that could be moved out too).