Use unsigned types for bitfields

Using signed types for bitfields results in undefined behaviour.
On sane two's complement machines using "char x:1;' results in a field capable
of taking the value 0 and -1. Proabbly not what you expect. Those constructs in
GB were used for booleans in structures sent over the network.
Changed to "unsigned char x:1;'
This commit is contained in:
Ivan Skytte Jørgensen
2015-11-16 13:57:22 +01:00
parent 8c19d9efdc
commit df5a4bff71
6 changed files with 66 additions and 66 deletions

76
Msg20.h

@ -103,7 +103,7 @@ class Msg20Request {
FacetValHash_t m_facetValHash;
char m_justGetFacets : 1 ;
unsigned char m_justGetFacets : 1 ;
// for sending msg20 request to another network
//int32_t m_hostIP;
@ -136,54 +136,54 @@ class Msg20Request {
char m_linksPerIpHost ;
char m_flags ;
char m_highlightQueryTerms :1;
char m_highlightDates :1; // for event dates
char m_wcache :1;
//char m_checkSitedb :1;
char m_getImageUrl :1;
char m_ratInSummary :1;
char m_countOutlinks :1;
char m_considerTitlesFromBody :1;
char m_getSummaryVector :1;
char m_showBanned :1;
//char m_excludeLinkText :1;
//char m_excludeMetaText :1;
//char m_hackFixWords :1;
//char m_hackFixPhrases :1;
char m_includeCachedCopy :1;
char m_getSectionVotingInfo :1; // in JSON for now
char m_getMatches :1;
char m_useLinkdbForInlinks :1;
char m_getTermListBuf :1;
//char m_getInlinks :1; // use m_getLinkInfo!
char m_getOutlinks :1;
char m_getTitleRec :1; // sets ptr_tr in reply
char m_maxInlinks :1;
char m_getGigabitVector :1;
char m_doLinkSpamCheck :1;
char m_isLinkSpam :1; // Msg25 uses for storage
char m_isSiteLinkInfo :1; // site link info?
char m_isDebug :1;
unsigned char m_highlightQueryTerms :1;
unsigned char m_highlightDates :1; // for event dates
unsigned char m_wcache :1;
//unsigned char m_checkSitedb :1;
unsigned char m_getImageUrl :1;
unsigned char m_ratInSummary :1;
unsigned char m_countOutlinks :1;
unsigned char m_considerTitlesFromBody :1;
unsigned char m_getSummaryVector :1;
unsigned char m_showBanned :1;
//unsigned char m_excludeLinkText :1;
//unsigned char m_excludeMetaText :1;
//unsigned char m_hackFixWords :1;
//unsigned char m_hackFixPhrases :1;
unsigned char m_includeCachedCopy :1;
unsigned char m_getSectionVotingInfo :1; // in JSON for now
unsigned char m_getMatches :1;
unsigned char m_useLinkdbForInlinks :1;
unsigned char m_getTermListBuf :1;
//unsigned char m_getInlinks :1; // use m_getLinkInfo!
unsigned char m_getOutlinks :1;
unsigned char m_getTitleRec :1; // sets ptr_tr in reply
unsigned char m_maxInlinks :1;
unsigned char m_getGigabitVector :1;
unsigned char m_doLinkSpamCheck :1;
unsigned char m_isLinkSpam :1; // Msg25 uses for storage
unsigned char m_isSiteLinkInfo :1; // site link info?
unsigned char m_isDebug :1;
// if true, calls Msg25 and fills in ptr_linkInfo/size_linkInfo
char m_computeLinkInfo :1;
unsigned char m_computeLinkInfo :1;
// if true, just calls TitleRec::getLinkInfo() to set ptr_linkInfo
char m_getLinkInfo :1;
unsigned char m_getLinkInfo :1;
// if this is true we will not compute the title, etc. of BAD inlinks
// deemed link spam
char m_onlyNeedGoodInlinks :1;
unsigned char m_onlyNeedGoodInlinks :1;
// if true, sets ptr_linkText, etc.
char m_getLinkText :1;
unsigned char m_getLinkText :1;
// if this is true then we set ptr_turkForm to be an input form
// for turking this event summary and title
char m_getTurkForm :1;
char m_showTurkInstructions :1;
char m_isTurkSpecialQuery :1;
char m_isMasterAdmin :1;
unsigned char m_getTurkForm :1;
unsigned char m_showTurkInstructions :1;
unsigned char m_isTurkSpecialQuery :1;
unsigned char m_isMasterAdmin :1;
// . this is for buzz.
// . this says to compute the <absScore2> tag in their xml feed.
// . the document receives a score of 0 if it does not match the query
// . can we just keep it a binary score? let's try that.
char m_checkForQueryMatch :1;
unsigned char m_checkForQueryMatch :1;
// serialize() converts these ptrs into offsets in m_buf[]
// and deserialize() converts them back into ptrs on the receiver's end

10
Msg22.h

@ -15,11 +15,11 @@ public:
int32_t m_niceness;
int32_t m_maxCacheAge;
collnum_t m_collnum;
char m_justCheckTfndb :1;
char m_getAvailDocIdOnly:1;
char m_doLoadBalancing :1;
char m_addToCache :1;
char m_inUse :1;
unsigned char m_justCheckTfndb :1;
unsigned char m_getAvailDocIdOnly:1;
unsigned char m_doLoadBalancing :1;
unsigned char m_addToCache :1;
unsigned char m_inUse :1;
char m_url[MAX_URL_LEN+1];
Msg22Request();

@ -534,7 +534,7 @@ class QueryTerm {
// . true if we are a word IN a phrase
// . used by IndexTable2's getWeightedScore()
char m_inPhrase;
char m_isWikiHalfStopBigram:1;
unsigned char m_isWikiHalfStopBigram:1;
// if a single word term, what are the term #'s of the 2 phrases
// we can be in? uses -1 to indicate none.
int32_t m_leftPhraseTermNum;

@ -560,19 +560,19 @@ class SpiderRequest {
// the new add url control will allow user to control link spidering
// on each url they add. they can also specify file:// instead of
// http:// to index local files. so we have to allow file://
/* char m_onlyAddSameDomainLinks :1; */
/* char m_onlyAddSameSubdomainLinks :1; */
/* char m_onlyDoNotAddLinksLinks :1; // max hopcount 1 */
/* char m_onlyDoNotAddLinksLinksLinks :1; // max hopcount 2 */
char m_ignoreDocUnchangedError:1;//reserved2a:1;
char m_recycleContent:1;//m_reserved2b:1;
char m_hasMediaExtension:1; // reserved2c:1;
char m_hasMediaExtensionValid:1;
/* unsigned char m_onlyAddSameDomainLinks :1; */
/* unsigned char m_onlyAddSameSubdomainLinks :1; */
/* unsigned char m_onlyDoNotAddLinksLinks :1; // max hopcount 1 */
/* unsigned char m_onlyDoNotAddLinksLinksLinks :1; // max hopcount 2 */
unsigned char m_ignoreDocUnchangedError:1;//reserved2a:1;
unsigned char m_recycleContent:1;//m_reserved2b:1;
unsigned char m_hasMediaExtension:1; // reserved2c:1;
unsigned char m_hasMediaExtensionValid:1;
char m_reserved2e:1;
char m_reserved2f:1;
char m_reserved2g:1;
char m_reserved2h:1;
unsigned char m_reserved2e:1;
unsigned char m_reserved2f:1;
unsigned char m_reserved2g:1;
unsigned char m_reserved2h:1;
//int32_t m_hopCount;
@ -895,7 +895,7 @@ class SpiderReply {
//
// XmlDoc::isSpam() returned true for it!
//char m_isSpam:1;
//unsigned char m_isSpam:1;
// was the page in rss format?
int32_t m_isRSS:1;
// was the page a permalink?

@ -86,10 +86,10 @@ class XmlNode {
//int32_t m_xmlParentTagNum; // set by Xml class
int16_t m_depth; // set by Xml class (xml depth only)
nodeid_t m_nodeId; // 0 for text,1 for xml tag, 1+ for html
char m_hasBackTag:1;
char m_isBreaking:1; // does tag (if it is) line break?
char m_isVisible:1;
char m_isSelfLink:1; // an a href tag link to self?
unsigned char m_hasBackTag:1;
unsigned char m_isBreaking:1; // does tag (if it is) line break?
unsigned char m_isVisible:1;
unsigned char m_isSelfLink:1; // an a href tag link to self?
int32_t m_pairTagNum; // paired opening or closing tag
// . "m_linkNum" references a link in Links.cpp
// . use for <a href> xml nodes only right now

10
seo.h

@ -319,11 +319,11 @@ public:
int16_t m_replyingHostId;
// was the query added from the m_extraQueryBuf which is set
// from the user-supplied textarea
char m_isManuallyAdded:1;
//char m_hasFullScore:1;
unsigned char m_isManuallyAdded:1;
//unsigned char m_hasFullScore:1;
// is it first in a linked list of msg99replies for the same query
// but different m_myDocId? (for related queries algo)
char m_isFirst:1;
unsigned char m_isFirst:1;
// score of the query
float m_myScore;
// docid of related query, set after getting reply
@ -384,7 +384,7 @@ public:
int32_t m_trafficSum;
// is it a related term? i.e. from a related query as opposed to
// a matching query. i.e. not contained by our doc..
char m_isRelatedTerm:1;
unsigned char m_isRelatedTerm:1;
//
// the following members are set by get*SCORED*InsertableTerms():
@ -572,7 +572,7 @@ public:
int16_t m_relatedDocIdNum;
// a flag. the head of the linked list?
char m_isFirst:1;
unsigned char m_isFirst:1;
// . sort by this first then by m_totalRelatedQueryImportance
// . the lower this value, the higher this query will be displayed