CVC: Since nobody checks the result from this function (strange!), I changed bool to void as the return type but left the result returned as comment.
| 122 | // CVC: Since nobody checks the result from this function (strange!), I changed |
| 123 | // bool to void as the return type but left the result returned as comment. |
| 124 | static void add_clump(thread_db* tdbb, USHORT type, USHORT len, const UCHAR* entry, ClumpOper mode) |
| 125 | { |
| 126 | /*********************************************** |
| 127 | * |
| 128 | * a d d _ c l u m p |
| 129 | * |
| 130 | *********************************************** |
| 131 | * |
| 132 | * Functional description |
| 133 | * Adds a clump to log/header page. |
| 134 | * mode |
| 135 | * 0 - add CLUMP_ADD |
| 136 | * 1 - replace CLUMP_REPLACE |
| 137 | * 2 - replace only! CLUMP_REPLACE_ONLY |
| 138 | * returns |
| 139 | * true - modified page |
| 140 | * false - nothing done => nobody checks this function's result. |
| 141 | * |
| 142 | **************************************/ |
| 143 | SET_TDBB(tdbb); |
| 144 | Database* dbb = tdbb->getDatabase(); |
| 145 | CHECK_DBB(dbb); |
| 146 | |
| 147 | err_post_if_database_is_readonly(dbb); |
| 148 | |
| 149 | WIN window(DB_PAGE_SPACE, HEADER_PAGE); |
| 150 | pag* page = CCH_FETCH(tdbb, &window, LCK_write, pag_header); |
| 151 | header_page* header = (header_page*) page; |
| 152 | USHORT* end_addr = &header->hdr_end; |
| 153 | |
| 154 | UCHAR* entry_p; |
| 155 | const UCHAR* clump_end; |
| 156 | if (mode != CLUMP_ADD) |
| 157 | { |
| 158 | const bool found = find_type(tdbb, &window, &page, LCK_write, type, &entry_p, &clump_end); |
| 159 | |
| 160 | // If we did'nt find it and it is REPLACE_ONLY, return |
| 161 | |
| 162 | if (!found && mode == CLUMP_REPLACE_ONLY) |
| 163 | { |
| 164 | CCH_RELEASE(tdbb, &window); |
| 165 | return; //false; |
| 166 | } |
| 167 | |
| 168 | // If not found, just go and add the entry |
| 169 | |
| 170 | if (found) |
| 171 | { |
| 172 | |
| 173 | // if same size, overwrite it |
| 174 | const USHORT oldLen = entry_p[1] + 2u; |
| 175 | |
| 176 | if (oldLen - 2u == len) |
| 177 | { |
| 178 | entry_p += 2; |
| 179 | if (len) |
| 180 | { |
| 181 | CCH_MARK_MUST_WRITE(tdbb, &window); |
no test coverage detected