void BodyPipe::setBodySize(uint64_t aBodySize)
{
assert(!bodySizeKnown());
- assert(aBodySize >= 0);
assert(thePutSize <= aBodySize);
// If this assert fails, we need to add code to check for eof and inform
http_hdr_type
httpHeaderIdByName(const char *name, size_t name_len, const HttpHeaderFieldInfo * info, int end)
{
- int i;
-
- for (i = 0; i < end; ++i) {
- if (name_len >= 0 && name_len != info[i].name.size())
- continue;
+ if (name_len > 0) {
+ for (int i = 0; i < end; ++i) {
+ if (name_len != info[i].name.size())
+ continue;
- if (!strncasecmp(name, info[i].name.termedBuf(),
- name_len < 0 ? info[i].name.size() + 1 : name_len))
- return info[i].id;
+ if (!strncasecmp(name, info[i].name.termedBuf(), name_len))
+ return info[i].id;
+ }
}
return HDR_BAD_HDR;
}
};
inline const char* GetHost(void) const { return host; };
- inline const int GetHostIsNumeric(void) const { return host_is_numeric; };
+ inline int GetHostIsNumeric(void) const { return host_is_numeric; };
#if USE_ADAPTATION
/// Returns possibly nil history, creating it if adapt. logging is enabled
\retval METHOD_OTHER the method is not recognized and has no unique ID
\retval * the method is on of the recognized HTTP methods.
*/
- _method_t const id() const { return theMethod; }
+ _method_t id() const { return theMethod; }
/** Get a char string representation of the method. */
- char const* image() const;
+ char const * image() const;
bool isCacheble() const;
bool purgesOthers() const;
String
String::substr(String::size_type from, String::size_type to) const
{
- Must(from >= 0 && from < size());
+// Must(from >= 0 && from < size());
+ Must(from < size());
Must(to > 0 && to <= size());
Must(to > from);
static int
aclHostDomainCompare( char *const &a, char * const &b)
{
- const char *h = (const char *)a;
- const char *d = (const char *)b;
+ const char *h = static_cast<const char *>(a);
+ const char *d = static_cast<const char *>(b);
return matchDomainName(h, d);
}
int
aclDomainCompare(T const &a, T const &b)
{
- char * const d1 = (char *const)b;
- char * const d2 = (char *const )a;
+ char * const d1 = static_cast<char *>(b);
+ char * const d2 = static_cast<char *>(a);
int ret;
ret = aclHostDomainCompare(d1, d2);
// we decided to do preview, now compute its size
- Must(wantedSize >= 0);
-
// cannot preview more than we can backup
size_t ad = min(wantedSize, TheBackupLimit);
void Adaptation::Icap::VirginBodyAct::progress(size_t size)
{
Must(active());
- Must(size >= 0);
+ Must(static_cast<int64_t>(size) >= 0);
theStart += static_cast<int64_t>(size);
}
void Adaptation::Icap::Preview::enable(size_t anAd)
{
// TODO: check for anAd not exceeding preview size limit
- Must(anAd >= 0);
Must(!enabled());
theAd = anAd;
theState = stWriting;
reader = NULL;
Must(io.flag == COMM_OK);
- Must(io.size >= 0);
if (!io.size) {
commEof = true;
}
- /*
- * paranoid check
- */
- assert((available.size() >= 0 && i->debt() >= 0) || i->debt() == -1);
-
if (!canPackMoreRanges()) {
debugs(33, 3, "clientPackRange: Returning because !canPackMoreRanges.");
}
ConnStateData *
-ClientHttpRequest::getConn()
-{
- if (!cbdataReferenceValid(conn_))
- return NULL;
-
- return conn_;
-}
-
-ConnStateData * const
ClientHttpRequest::getConn() const
{
if (!cbdataReferenceValid(conn_))
_SQUID_INLINE_ StoreEntry *loggingEntry() const;
void loggingEntry(StoreEntry *);
- _SQUID_INLINE_ ConnStateData * getConn();
- _SQUID_INLINE_ ConnStateData * const getConn() const;
+ _SQUID_INLINE_ ConnStateData * getConn() const;
_SQUID_INLINE_ void setConn(ConnStateData *);
HttpRequest *request; /* Parsed URL ... */
char *uri;
", id = 0x" << std::hex << q->id);
q->callback = callback;
-
q->callback_data = cbdataReference(data);
q->start_t = current_time;
idnsCacheQuery(q);
-
idnsSendQuery(q);
}
", id = 0x" << std::hex << q->id);
q->callback = callback;
-
q->callback_data = cbdataReference(data);
q->start_t = current_time;
idnsCacheQuery(q);
-
idnsSendQuery(q);
}
IOStats.Ftp.read_hist[bin]++;
}
- if (io.flag != COMM_OK || io.size < 0) {
+ if (io.flag != COMM_OK) {
debugs(50, ignoreErrno(io.xerrno) ? 3 : DBG_IMPORTANT,
"ftpDataRead: read error: " << xstrerr(io.xerrno));
fd_bytes(io.fd, io.size, FD_READ);
}
- if (io.flag != COMM_OK || io.size < 0) {
+ if (io.flag != COMM_OK) {
debugs(50, ignoreErrno(io.xerrno) ? 3 : DBG_IMPORTANT,
"ftpReadControlReply: read error: " << xstrerr(io.xerrno));
} else {
failed(ERR_READ_ERROR, io.xerrno);
/* failed closes ctrl.fd and frees ftpState */
- return;
}
-
return;
}
debugs(84, 5, "helperHandleRead: " << len << " bytes from " << hlp->id_name << " #" << srv->index + 1);
- if (flag != COMM_OK || len <= 0) {
- if (len < 0)
- debugs(84, 1, "helperHandleRead: FD " << fd << " read: " << xstrerror());
-
+ if (flag != COMM_OK || len == 0) {
comm_close(fd);
-
return;
}
hlp->id_name << " #" << srv->index + 1);
- if (flag != COMM_OK || len <= 0) {
- if (len < 0)
- debugs(84, 1, "helperStatefulHandleRead: FD " << fd << " read: " << xstrerror());
-
+ if (flag != COMM_OK || len == 0) {
comm_close(fd);
-
return;
}
/* some external code may have blindly memset a parent. */
/* thats okay, our default is known */
if ( IsAnyAddr() ) {
- memcpy(buf,"::\0", min((const unsigned int)3,blen));
+ memcpy(buf,"::\0", min(static_cast<unsigned int>(3),blen));
return buf;
}
/* However IPv4 CAN. */
if ( force == AF_INET && !IsIPv4() ) {
if ( IsIPv6() ) {
- memcpy(buf, "{!IPv4}\0", min((const unsigned int)8,blen));
+ memcpy(buf, "{!IPv4}\0", min(static_cast<unsigned int>(8),blen));
}
return buf;
}
force << "). accepted={" << AF_UNSPEC << "," << AF_INET << "," << AF_INET6 << "}");
fprintf(stderr,"WARNING: Corrupt IP Address details OR required to display in unknown format (%d). accepted={%d,%d,%d} ",
force, AF_UNSPEC, AF_INET, AF_INET6);
- memcpy(buf,"dead:beef::\0", min((const unsigned int)13,blen));
+ memcpy(buf,"dead:beef::\0", min(static_cast<unsigned int>(13),blen));
assert(false);
}
StoreEntry::write (StoreIOBuffer writeBuffer)
{
assert(mem_obj != NULL);
- assert(writeBuffer.length >= 0);
/* This assert will change when we teach the store to update */
PROF_start(StoreEntry_write);
assert(store_status == STORE_PENDING);
if (!fd_closed(server.fd()))
commSetTimeout(server.fd(), Config.Timeout.read, tunnelTimeout, this);
- if (len < 0 || errcode)
+ if (errcode)
from.error (xerrno);
else if (len == 0 || fd_closed(to.fd())) {
comm_close(from.fd());
{
debugs(26, 3, "tunnelWriteServer: FD " << server.fd() << ", " << len << " bytes written");
- if (flag == COMM_ERR_CLOSING)
- return;
-
/* Error? */
- if (len < 0 || flag != COMM_OK) {
- server.error(xerrno); // may call comm_close
+ if (flag != COMM_OK) {
+ if (flag != COMM_ERR_CLOSING)
+ server.error(xerrno); // may call comm_close
return;
}
{
debugs(26, 3, "tunnelWriteClient: FD " << client.fd() << ", " << len << " bytes written");
- if (flag == COMM_ERR_CLOSING)
- return;
-
/* Error? */
- if (len < 0 || flag != COMM_OK) {
- client.error(xerrno); // may call comm_close
+ if (flag != COMM_OK) {
+ if (flag != COMM_ERR_CLOSING)
+ client.error(xerrno); // may call comm_close
return;
}
char *buf = urnState->reqbuf;
StoreIOBuffer tempBuffer;
- debugs(52, 3, "urnHandleReply: Called with size=" << (unsigned int)result.length << ".");
+ debugs(52, 3, "urnHandleReply: Called with size=" << result.length << ".");
- if (EBIT_TEST(urlres_e->flags, ENTRY_ABORTED) || result.length == 0 || result.flags.error < 0) {
+ if (EBIT_TEST(urlres_e->flags, ENTRY_ABORTED) || result.length == 0 || result.flags.error) {
urnHandleReplyError(urnState, urlres_e);
return;
}
void
WhoisState::readReply (int fd, char *aBuffer, size_t aBufferLength, comm_err_t flag, int xerrno)
{
- int do_next_read = 0;
-
/* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us */
-
- if (flag == COMM_ERR_CLOSING) {
+ if (flag == COMM_ERR_CLOSING)
return;
- }
aBuffer[aBufferLength] = '\0';
debugs(75, 3, "whoisReadReply: FD " << fd << " read " << aBufferLength << " bytes");
debugs(75, 5, "{" << aBuffer << "}");
- if (flag == COMM_OK && aBufferLength > 0) {
- if (!dataWritten)
- setReplyToOK(entry);
-
- kb_incr(&statCounter.server.all.kbytes_in, aBufferLength);
-
- kb_incr(&statCounter.server.http.kbytes_in, aBufferLength);
-
- /* No range support, we always grab it all */
- dataWritten = true;
-
- entry->append(aBuffer, aBufferLength);
-
- entry->flush();
-
- do_next_read = 1;
- } else if (flag != COMM_OK || aBufferLength < 0) {
+ if (flag != COMM_OK) {
debugs(50, 2, "whoisReadReply: FD " << fd << ": read failure: " << xstrerror() << ".");
if (ignoreErrno(errno)) {
- do_next_read = 1;
+ comm_read(fd, aBuffer, BUFSIZ, whoisReadReply, this);
} else {
ErrorState *err;
err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, fwd->request);
err->xerrno = errno;
fwd->fail(err);
comm_close(fd);
- do_next_read = 0;
}
- } else {
- entry->timestampsSet();
- entry->flush();
-
- if (!EBIT_TEST(entry->flags, RELEASE_REQUEST))
- entry->setPublicKey();
+ return;
+ }
- fwd->complete();
+ if (aBufferLength > 0) {
+ if (!dataWritten)
+ setReplyToOK(entry);
- debugs(75, 3, "whoisReadReply: Done: " << entry->url() );
+ kb_incr(&statCounter.server.all.kbytes_in, aBufferLength);
+ kb_incr(&statCounter.server.http.kbytes_in, aBufferLength);
- comm_close(fd);
+ /* No range support, we always grab it all */
+ dataWritten = true;
+ entry->append(aBuffer, aBufferLength);
+ entry->flush();
- do_next_read = 0;
+ comm_read(fd, aBuffer, BUFSIZ, whoisReadReply, this);
+ return;
}
- if (do_next_read)
- comm_read(fd, aBuffer, BUFSIZ, whoisReadReply, this);
+ /* no bytes read. stop reading */
+ entry->timestampsSet();
+ entry->flush();
+
+ if (!EBIT_TEST(entry->flags, RELEASE_REQUEST))
+ entry->setPublicKey();
+
+ fwd->complete();
+ debugs(75, 3, "whoisReadReply: Done: " << entry->url());
+ comm_close(fd);
}
static void
{
public:
std::ostream &serialise(std::ostream &);
- int const getAnInt() const;
+ int getAnInt() const;
char const *getACString() const;
};
return aStream;
}
-int const
+int
StreamTest::getAnInt() const
{
return 5;