  1383 |       {"Preprint", 8, "stationery-preprinted"},
  1384 |       {"Recycled", -1, "stationery-recycled"},
  1385 |       {"Transparen", 10, "transparency"},
  1386 |     };
  1387 |     const int num_standard_types = (int)(sizeof(standard_types) / sizeof(standard_types[0]));
  1388 | 					/* Length of the standard_types array */
  1389 |     int match_counts[sizeof(standard_types) / sizeof(standard_types[0])] = {0};
  1390 | 					/* Number of matches for each standard type */
  1391 |
  1392 |     if ((pc->types = calloc((size_t)media_type->num_choices, sizeof(pwg_map_t))) == NULL)
  1393 |     {
  1394 |       DEBUG_printf("_ppdCacheCreateWithPPD: Unable to allocate %d pwg_map_t's for MediaType.", media_type->num_choices);
  1395 |       goto create_error;
  1396 |     }
  1397 |
  1398 |     pc->num_types = media_type->num_choices;
  1399 |
  1400 |     for (i = media_type->num_choices, choice = media_type->choices,
  1401 |              map = pc->types;
  1402 | 	 i > 0;
  1403 | 	 i --, choice ++, map ++)
  1404 |     {
  1405 |       pwg_name = NULL;
  1406 |
  1407 |       for (j = 0; j < num_standard_types; j ++)
  1408 |       {
  1409 |         if (standard_types[j].match_length <= 0)
  1410 |         {
  1411 |           if (!_cups_strcasecmp(choice->choice, standard_types[j].ppd_name))
  1412 |           {
  1413 |             pwg_name = standard_types[j].pwg_name;
  1414 |             match_counts[j] ++;
  1415 |           }
  1416 |         }
  1417 |         else if (!_cups_strncasecmp(choice->choice, standard_types[j].ppd_name, (size_t)standard_types[j].match_length))
  1418 |         {
  1419 |           pwg_name = standard_types[j].pwg_name;
  1420 |           match_counts[j] ++;
  1421 |         }
  1422 |       }
  1423 |
  1424 |       if (!pwg_name)
  1425 |       {
  1426 |        /*
  1427 |         * Convert PPD name to lowercase...
  1428 | 	*/
  1429 |
  1430 |         pwg_name = pwg_keyword;
  1431 | 	pwg_unppdize_name(choice->choice, pwg_keyword, sizeof(pwg_keyword),
  1432 | 	                  "_");
  1433 |       }
  1434 |
  1435 |       map->pwg = strdup(pwg_name);
  1436 |       map->ppd = strdup(choice->choice);
  1437 |     }
  1438 |
  1439 |    /*
  1440 |     * Since three PPD name patterns can map to "auto", their match counts
  1441 |     * should each be the count of all three combined.
  1442 |     */
  1443 |
  1444 |     i = match_counts[0] + match_counts[1] + match_counts[2];
  1445 |     match_counts[0] = match_counts[1] = match_counts[2] = i;
  1446 |
  1447 |     for (i = 0, choice = media_type->choices, map = pc->types;
  1448 |       i < media_type->num_choices;
  1449 |       i ++, choice ++, map ++)
  1450 |     {
  1451 |      /*
  1452 |       * If there are two matches for any standard PWG media type, don't give
  1453 |       * the PWG name to either one.
  1454 |       */
  1455 |
  1456 |       for (j = 0; j < num_standard_types; j ++)
  1457 |       {
  1458 |         if (match_counts[j] > 1 && !strcmp(map->pwg, standard_types[j].pwg_name))
  1459 |         {
  1460 |           free(map->pwg);
  1461 |           pwg_unppdize_name(choice->choice, pwg_keyword, sizeof(pwg_keyword), "_");
  1462 |           map->pwg = strdup(pwg_keyword);
  1463 |         }
  1464 |       }
  1465 |
  1466 |      /*
  1467 |       * Add localized text for PWG keyword to message catalog...
  1468 |       */
  1469 |
  1470 |       snprintf(msg_id, sizeof(msg_id), "media-type.%s", map->pwg);
  1471 |       ppd_get_strings(ppd, langs, "MediaType", choice, msg_id);
  1472 |     }
  1473 |   }
  1474 |
  1475 |  /*
  1476 |   * Copy and convert OutputBin data...
  1477 |   */
  1478 |
  1479 |   if ((output_bin = ppdFindOption(ppd, "OutputBin")) != NULL)
  1480 |   {
  1481 |     if ((pc->bins = calloc((size_t)output_bin->num_choices, sizeof(pwg_map_t))) == NULL)
  1482 |     {
> 1483 |       DEBUG_printf("_ppdCacheCreateWithPPD: Unable to allocate %d pwg_map_t's for OutputBin.", output_bin->num_choices);
  1484 |       goto create_error;
  1485 |     }
  1486 |
  1487 |     pc->num_bins = output_bin->num_choices;
  1488 |
  1489 |     for (i = output_bin->num_choices, choice = output_bin->choices,
  1490 |              map = pc->bins;
  1491 | 	 i > 0;
  1492 | 	 i --, choice ++, map ++)
  1493 |     {
  1494 |       pwg_unppdize_name(choice->choice, pwg_keyword, sizeof(pwg_keyword), "_");
  1495 |
  1496 |       map->pwg = strdup(pwg_keyword);
  1497 |       map->ppd = strdup(choice->choice);
  1498 |
  1499 |      /*
  1500 |       * Add localized text for PWG keyword to message catalog...
  1501 |       */
  1502 |
  1503 |       snprintf(msg_id, sizeof(msg_id), "output-bin.%s", pwg_keyword);
  1504 |       ppd_get_strings(ppd, langs, "OutputBin", choice, msg_id);
  1505 |     }
  1506 |   }
  1507 |
  1508 |   if ((ppd_attr = ppdFindAttr(ppd, "APPrinterPreset", NULL)) != NULL)
  1509 |   {
  1510 |    /*
  1511 |     * Copy and convert APPrinterPreset (output-mode + print-quality) data...
  1512 |     */
  1513 |
  1514 |     const char	*quality,		/* com.apple.print.preset.quality value */
  1515 | 		*output_mode,		/* com.apple.print.preset.output-mode value */
  1516 | 		*color_model_val,	/* ColorModel choice */
  1517 | 		*graphicsType,		/* com.apple.print.preset.graphicsType value */
  1518 | 		*media_front_coating;	/* com.apple.print.preset.media-front-coating value */
  1519 |
  1520 |     do
  1521 |     {
  1522 | #if 0
  1523 |      /*
  1524 |       * Add localized text for PWG keyword to message catalog...
  1525 |       */
  1526 |
  1527 |       snprintf(msg_id, sizeof(msg_id), "preset-name.%s", ppd_attr->spec);
  1528 |       pwg_add_message(pc->strings, msg_id, ppd_attr->text);
  1529 | #endif // 0
  1530 |
  1531 |      /*
  1532 |       * Get the options for this preset...
  1533 |       */
  1534 |
  1535 |       num_options = _ppdParseOptions(ppd_attr->value, 0, &options,
  1536 |                                      _PPD_PARSE_ALL);
  1537 |
  1538 |       if ((quality = cupsGetOption("com.apple.print.preset.quality",
  1539 |                                    num_options, options)) != NULL)
  1540 |       {
  1541 |        /*
  1542 |         * Get the print-quality for this preset...
  1543 | 	*/
  1544 |
  1545 | 	if (!strcmp(quality, "low"))
  1546 | 	  pwg_print_quality = _PWG_PRINT_QUALITY_DRAFT;
  1547 | 	else if (!strcmp(quality, "high"))
  1548 | 	  pwg_print_quality = _PWG_PRINT_QUALITY_HIGH;
  1549 | 	else
  1550 | 	  pwg_print_quality = _PWG_PRINT_QUALITY_NORMAL;
  1551 |
  1552 |        /*
  1553 | 	* Ignore graphicsType "Photo" presets that are not high quality.
  1554 | 	*/
  1555 |
  1556 | 	graphicsType = cupsGetOption("com.apple.print.preset.graphicsType",
  1557 | 				      num_options, options);
  1558 |
  1559 | 	if (pwg_print_quality != _PWG_PRINT_QUALITY_HIGH && graphicsType &&
  1560 | 	    !strcmp(graphicsType, "Photo"))
  1561 | 	  continue;
  1562 |
  1563 |        /*
  1564 | 	* Ignore presets for normal and draft quality where the coating
  1565 | 	* isn't "none" or "autodetect".
  1566 | 	*/
  1567 |
  1568 | 	media_front_coating = cupsGetOption(
  1569 | 	                          "com.apple.print.preset.media-front-coating",
  1570 | 			          num_options, options);
  1571 |
  1572 |         if (pwg_print_quality != _PWG_PRINT_QUALITY_HIGH &&
  1573 | 	    media_front_coating &&
  1574 | 	    strcmp(media_front_coating, "none") &&
  1575 | 	    strcmp(media_front_coating, "autodetect"))
  1576 | 	  continue;
  1577 |
  1578 |        /*
  1579 |         * Get the output mode for this preset...
  1580 | 	*/
  1581 |
  1582 |         output_mode     = cupsGetOption("com.apple.print.preset.output-mode",
  1583 | 	                                num_options, options);

Reach line at /src/cups/cups/ppd-cache.c:1483 (observed count 0).


  1266 | {
  1267 |   // Range check input...
  1268 |   if (!fp || (fp->mode != 'w' && fp->mode != 's'))
  1269 |     return (-1);
  1270 |
  1271 |   if (fp->mode == 's')
  1272 |   {
  1273 |     // Send character immediately over socket...
  1274 |     char ch;				// Output character
  1275 |
  1276 |
  1277 |     ch = (char)c;
  1278 |
  1279 |     if (send(fp->fd, &ch, 1, 0) < 1)
  1280 |       return (-1);
  1281 |   }
  1282 |   else
  1283 |   {
  1284 |     // Buffer it up...
  1285 |     if (fp->ptr >= fp->end)
  1286 |       if (cupsFileFlush(fp))
  1287 | 	return (-1);
  1288 |
  1289 |     *(fp->ptr) ++ = (char)c;
  1290 |   }
  1291 |
  1292 |   fp->pos ++;
  1293 |
  1294 |   DEBUG_printf("4cupsFilePutChar: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
  1295 |
  1296 |   return (0);
  1297 | }
  1298 |
  1299 |
  1300 | //
  1301 | // 'cupsFilePutConf()' - Write a configuration line.
  1302 | //
  1303 | // This function handles any escaping of the value.
  1304 | //
  1305 | // @since CUPS 1.4@
  1306 | //
  1307 |
  1308 | ssize_t					// O - Number of bytes written or -1 on error
  1309 | cupsFilePutConf(cups_file_t *fp,	// I - CUPS file
  1310 |                 const char *directive,	// I - Directive
  1311 | 		const char *value)	// I - Value
  1312 | {
  1313 |   ssize_t	bytes,			// Number of bytes written
  1314 | 		temp;			// Temporary byte count
  1315 |
  1316 |
  1317 |   if (!fp || !directive || !*directive)
  1318 |     return (-1);
  1319 |
  1320 |   if ((bytes = cupsFilePuts(fp, directive)) < 0)
  1321 |     return (-1);
  1322 |
  1323 |   if (value && *value)
  1324 |   {
  1325 |     const char	*start,			// Start of current fragment
  1326 | 		*ptr;			// Pointer into value
  1327 |
  1328 |     if (cupsFilePutChar(fp, ' ') < 0)
  1329 |       return (-1);
  1330 |     bytes ++;
  1331 |
  1332 |     for (start = ptr = value; *ptr; ptr ++)
  1333 |     {
  1334 |       if (strchr("#\\\n\r", *ptr) != NULL)
  1335 |       {
  1336 |         // Character that needs to be escaped...
  1337 |         if (ptr > start)
  1338 |         {
  1339 |           // Write unescaped portion...
  1340 | 	  if ((temp = cupsFileWrite(fp, start, (size_t)(ptr - start))) < 0)
  1341 | 	    return (-1);
  1342 |
  1343 | 	  bytes += temp;
  1344 |         }
  1345 |
  1346 |         start = ptr + 1;
  1347 |
  1348 |         if (*ptr == '\\')
  1349 |         {
  1350 |           // "\" (for escaping)
  1351 |           if (cupsFilePuts(fp, "\\\\") < 0)
  1352 |             return (-1);
  1353 |         }
  1354 |         else if (*ptr == '#')
  1355 |         {
  1356 |           // "#" (for comment)
  1357 |           if (cupsFilePuts(fp, "\\#") < 0)
  1358 |             return (-1);
  1359 |         }
  1360 |         else if (*ptr == '\n')
  1361 |         {
  1362 |           // LF
  1363 |           if (cupsFilePuts(fp, "\\n") < 0)
  1364 |             return (-1);
  1365 |         }
> 1366 |         else if (cupsFilePuts(fp, "\\r") < 0)
  1367 |         {
  1368 | 	  return (-1);
  1369 | 	}
  1370 |
  1371 | 	bytes += 2;
  1372 |       }
  1373 |     }
  1374 |
  1375 |     if (ptr > start)
  1376 |     {
  1377 |       // Write remaining unescaped portion...
  1378 |       if ((temp = cupsFileWrite(fp, start, (size_t)(ptr - start))) < 0)
  1379 | 	return (-1);
  1380 |
  1381 |       bytes += temp;
  1382 |     }
  1383 |   }
  1384 |
  1385 |   if (cupsFilePutChar(fp, '\n') < 0)
  1386 |     return (-1);
  1387 |   else
  1388 |     return (bytes + 1);
  1389 | }
  1390 |
  1391 |
  1392 | //
  1393 | // 'cupsFilePuts()' - Write a string.
  1394 | //
  1395 | // Like the @code fputs@ function, no newline is appended to the string.
  1396 | //
  1397 | // @since CUPS 1.2@
  1398 | //
  1399 |
  1400 | int					// O - Number of bytes written or -1 on error
  1401 | cupsFilePuts(cups_file_t *fp,		// I - CUPS file
  1402 |              const char  *s)		// I - String to write
  1403 | {
  1404 |   ssize_t	bytes;			// Bytes to write
  1405 |
  1406 |
  1407 |   // Range check input...
  1408 |   if (!fp || !s || (fp->mode != 'w' && fp->mode != 's'))
  1409 |     return (-1);
  1410 |
  1411 |   // Write the string...
  1412 |   bytes = (ssize_t)strlen(s);
  1413 |
  1414 |   if (fp->mode == 's')
  1415 |   {
  1416 |     if (cups_write(fp, s, (size_t)bytes) < 0)
  1417 |       return (-1);
  1418 |
  1419 |     fp->pos += bytes;
  1420 |
  1421 |     DEBUG_printf("4cupsFilePuts: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
  1422 |
  1423 |     return ((int)bytes);
  1424 |   }
  1425 |
  1426 |   if ((fp->ptr + bytes) > fp->end)
  1427 |     if (cupsFileFlush(fp))
  1428 |       return (-1);
  1429 |
  1430 |   fp->pos += bytes;
  1431 |
  1432 |   DEBUG_printf("4cupsFilePuts: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos);
  1433 |
  1434 |   if ((size_t)bytes > sizeof(fp->buf))
  1435 |   {
  1436 |     if (fp->compressed)
  1437 |       return ((int)cups_compress(fp, s, (size_t)bytes));
  1438 |     else
  1439 |       return ((int)cups_write(fp, s, (size_t)bytes));
  1440 |   }
  1441 |   else
  1442 |   {
  1443 |     memcpy(fp->ptr, s, (size_t)bytes);
  1444 |     fp->ptr += bytes;
  1445 |
  1446 |     if (fp->is_stdio && cupsFileFlush(fp))
  1447 |       return (-1);
  1448 |     else
  1449 |       return ((int)bytes);
  1450 |   }
  1451 | }
  1452 |
  1453 |
  1454 | //
  1455 | // 'cupsFileRead()' - Read from a file.
  1456 | //
  1457 | // @since CUPS 1.2@
  1458 | //
  1459 |
  1460 | ssize_t					// O - Number of bytes read or -1 on error
  1461 | cupsFileRead(cups_file_t *fp,		// I - CUPS file
  1462 |              char        *buf,		// O - Buffer
  1463 | 	     size_t      bytes)		// I - Number of bytes to read
  1464 | {
  1465 |   size_t	total;			// Total bytes read
  1466 |   ssize_t	count;			// Bytes read

Reach line at /src/cups/cups/file.c:1366 (observed count 0).


  1087 |
  1088 |     if (a->alloc_elements == 0)
  1089 |     {
  1090 |       count = 16;
  1091 |       temp  = malloc((size_t)count * sizeof(void *));
  1092 |     }
  1093 |     else
  1094 |     {
  1095 |       if (a->alloc_elements < 1024)
  1096 |         count = a->alloc_elements * 2;
  1097 |       else
  1098 |         count = a->alloc_elements + 1024;
  1099 |
  1100 |       temp = realloc(a->elements, (size_t)count * sizeof(void *));
  1101 |     }
  1102 |
  1103 |     DEBUG_printf("9cups_array_add: count=" CUPS_LLFMT, CUPS_LLCAST count);
  1104 |
  1105 |     if (!temp)
  1106 |     {
  1107 |       DEBUG_puts("9cups_array_add: allocation failed, returning 0");
  1108 |       return (0);
  1109 |     }
  1110 |
  1111 |     a->alloc_elements = count;
  1112 |     a->elements       = temp;
  1113 |   }
  1114 |
  1115 |   // Find the insertion point for the new element; if there is no
  1116 |   // compare function or elements, just add it to the beginning or end...
  1117 |   if (!a->num_elements || !a->compare)
  1118 |   {
  1119 |     // No elements or comparison function, insert/append as needed...
  1120 |     if (insert)
  1121 |       current = 0;			// Insert at beginning
  1122 |     else
  1123 |       current = a->num_elements;	// Append to the end
  1124 |   }
  1125 |   else
  1126 |   {
  1127 |     // Do a binary search for the insertion point...
  1128 |     current = cups_array_find(a, e, a->insert, &diff);
  1129 |
  1130 |     if (diff > 0)
  1131 |     {
  1132 |       // Insert after the current element...
  1133 |       current ++;
  1134 |     }
  1135 |     else if (!diff)
  1136 |     {
  1137 |       // Compared equal, make sure we add to the beginning or end of
  1138 |       // the current run of equal elements...
  1139 |       a->unique = 0;
  1140 |
  1141 |       if (insert)
  1142 |       {
  1143 |         // Insert at beginning of run...
  1144 | 	while (current > 0 && !(*(a->compare))(e, a->elements[current - 1], a->data))
  1145 |           current --;
  1146 |       }
  1147 |       else
  1148 |       {
  1149 |         // Append at end of run...
  1150 | 	do
  1151 | 	{
  1152 |           current ++;
  1153 | 	}
  1154 | 	while (current < a->num_elements && !(*(a->compare))(e, a->elements[current], a->data));
  1155 |       }
  1156 |     }
  1157 |   }
  1158 |
  1159 |   // Insert or append the element...
  1160 |   if (current < a->num_elements)
  1161 |   {
  1162 |     // Shift other elements to the right...
  1163 |     memmove(a->elements + current + 1, a->elements + current, (size_t)(a->num_elements - current) * sizeof(void *));
  1164 |
  1165 |     if (a->current >= current)
  1166 |       a->current ++;
  1167 |
  1168 |     for (i = 0; i < a->num_saved; i ++)
  1169 |     {
  1170 |       if (a->saved[i] >= current)
  1171 | 	a->saved[i] ++;
  1172 |     }
  1173 |
  1174 |     DEBUG_printf("9cups_array_add: insert element at index " CUPS_LLFMT, CUPS_LLCAST current);
  1175 |   }
  1176 | #ifdef DEBUG
  1177 |   else
  1178 |   {
  1179 |     DEBUG_printf("9cups_array_add: append element at " CUPS_LLFMT, CUPS_LLCAST current);
  1180 |   }
  1181 | #endif // DEBUG
  1182 |
  1183 |   if (a->copyfunc)
  1184 |   {
  1185 |     if ((a->elements[current] = (a->copyfunc)(e, a->data)) == NULL)
  1186 |     {
> 1187 |       DEBUG_puts("8cups_array_add: Copy function returned NULL, returning 0");
  1188 |       return (0);
  1189 |     }
  1190 |   }
  1191 |   else
  1192 |   {
  1193 |     a->elements[current] = e;
  1194 |   }
  1195 |
  1196 |   a->num_elements ++;
  1197 |   a->insert = current;
  1198 |
  1199 |   DEBUG_puts("9cups_array_add: returning 1");
  1200 |
  1201 |   return (1);
  1202 | }
  1203 |
  1204 |
  1205 | //
  1206 | // 'cups_array_find()' - Find an element in the array.
  1207 | //
  1208 |
  1209 | static int				// O - Index of match
  1210 | cups_array_find(cups_array_t *a,	// I - Array
  1211 |         	void         *e,	// I - Element
  1212 | 		int          prev,	// I - Previous index
  1213 | 		int          *rdiff)	// O - Difference of match
  1214 | {
  1215 |   int	left,				// Left side of search
  1216 | 	right,				// Right side of search
  1217 | 	current,			// Current element
  1218 | 	diff;				// Comparison with current element
  1219 |
  1220 |
  1221 |   DEBUG_printf("7cups_array_find(a=%p, e=%p, prev=%d, rdiff=%p)", (void *)a, e, prev, (void *)rdiff);
  1222 |
  1223 |   if (a->compare)
  1224 |   {
  1225 |     // Do a binary search for the element...
  1226 |     DEBUG_puts("9cups_array_find: binary search");
  1227 |
  1228 |     if (prev >= 0 && prev < a->num_elements)
  1229 |     {
  1230 |       // Start search on either side of previous...
  1231 |       if ((diff = (*(a->compare))(e, a->elements[prev], a->data)) == 0 || (diff < 0 && prev == 0) || (diff > 0 && prev == (a->num_elements - 1)))
  1232 |       {
  1233 |         // Exact or edge match, return it!
  1234 |         DEBUG_printf("9cups_array_find: Returning %d, diff=%d", prev, diff);
  1235 |
  1236 | 	*rdiff = diff;
  1237 |
  1238 | 	return (prev);
  1239 |       }
  1240 |       else if (diff < 0)
  1241 |       {
  1242 |         // Start with previous on right side...
  1243 | 	left  = 0;
  1244 | 	right = prev;
  1245 |       }
  1246 |       else
  1247 |       {
  1248 |         // Start with previous on left side...
  1249 |         left  = prev;
  1250 | 	right = a->num_elements - 1;
  1251 |       }
  1252 |     }
  1253 |     else
  1254 |     {
  1255 |       // Start search in the middle...
  1256 |       left  = 0;
  1257 |       right = a->num_elements - 1;
  1258 |     }
  1259 |
  1260 |     do
  1261 |     {
  1262 |       current = (left + right) / 2;
  1263 |       diff    = (*(a->compare))(e, a->elements[current], a->data);
  1264 |
  1265 |       DEBUG_printf("9cups_array_find: left=%d, right=%d, current=%d, diff=%d", left, right, current, diff);
  1266 |
  1267 |       if (diff == 0)
  1268 | 	break;
  1269 |       else if (diff < 0)
  1270 | 	right = current;
  1271 |       else
  1272 | 	left = current;
  1273 |     }
  1274 |     while ((right - left) > 1);
  1275 |
  1276 |     if (diff != 0)
  1277 |     {
  1278 |       // Check the last 1 or 2 elements...
  1279 |       if ((diff = (*(a->compare))(e, a->elements[left], a->data)) <= 0)
  1280 |       {
  1281 |         current = left;
  1282 |       }
  1283 |       else
  1284 |       {
  1285 |         diff    = (*(a->compare))(e, a->elements[right], a->data);
  1286 |         current = right;
  1287 |       }

Reach line at /src/cups/cups/array.c:1187 (observed count 0).


  1315 |       {
  1316 |         // Something we don't understand...
  1317 |         DEBUG_printf("2_cupsSetDefaults: Unknown FilterType '%s'.", ptr);
  1318 |       }
  1319 |     }
  1320 |   }
  1321 |
  1322 |   DEBUG_printf("1_cupsSetDefaults: FilterType value 0x%x mask 0x%x", cg->filter_type, cg->filter_type_mask);
  1323 |
  1324 |   DEBUG_printf("1_cupsSetDefaults: AllowAnyRoot %s", cg->any_root ? "Yes" : "No");
  1325 |   DEBUG_printf("1_cupsSetDefaults: AllowExpiredCerts %s", cg->expired_certs ? "Yes" : "No");
  1326 |   DEBUG_printf("1_cupsSetDefaults: DigestOptions %s", cg->digestoptions == _CUPS_DIGESTOPTIONS_DENYMD5 ? "DenyMD5" : "None");
  1327 |   DEBUG_printf("1_cupsSetDefaults: Encryption %s", encryptions[cg->encryption]);
  1328 |   DEBUG_printf("1_cupsSetDefaults: ServerName %s", cg->servername);
  1329 |   DEBUG_printf("1_cupsSetDefaults: SSLOptions%s%s%s%s Min%s Max%s", cc.ssl_options == _HTTP_TLS_NONE ? " none" : "", (cc.ssl_options & _HTTP_TLS_ALLOW_RC4) ? " AllowRC4" : "", (cc.ssl_options & _HTTP_TLS_ALLOW_DH) ? " AllowDH" : "", (cc.ssl_options & _HTTP_TLS_DENY_CBC) ? " DenyCBC" : "", tls_versions[cc.ssl_min_version], tls_versions[cc.ssl_max_version]);
  1330 |   DEBUG_printf("1_cupsSetDefaults: TrustOnFirstUse %s", cg->trust_first ? "Yes" : "No");
  1331 |   DEBUG_printf("1_cupsSetDefaults: User %s", cg->user);
  1332 |   DEBUG_printf("1_cupsSetDefaults: UserAgentTokens %s", uatokens[cg->uatokens]);
  1333 |   DEBUG_printf("1_cupsSetDefaults: ValidateCerts %s", cg->validate_certs ? "Yes" : "No");
  1334 |
  1335 |   _httpTLSSetOptions(cc.ssl_options | _HTTP_TLS_SET_DEFAULT, cc.ssl_min_version, cc.ssl_max_version);
  1336 |
  1337 |   cg->client_conf_loaded = true;
  1338 | }
  1339 |
  1340 |
  1341 | #ifdef __APPLE__
  1342 | //
  1343 | // 'cups_apple_get_boolean()' - Get a boolean setting from the CUPS preferences.
  1344 | //
  1345 |
  1346 | static int				// O - 1 if set, 0 otherwise
  1347 | cups_apple_get_boolean(
  1348 |     CFStringRef key,			// I - Key (name)
  1349 |     int         *value)			// O - Boolean value
  1350 | {
  1351 |   Boolean	bval,			// Preference value
  1352 | 		bval_set;		// Value is set?
  1353 |
  1354 |
  1355 |   bval = CFPreferencesGetAppBooleanValue(key, kCUPSPrintingPrefs, &bval_set);
  1356 |
  1357 |   if (bval_set)
  1358 |     *value = (int)bval;
  1359 |
  1360 |   return ((int)bval_set);
  1361 | }
  1362 |
  1363 |
  1364 | //
  1365 | // 'cups_apple_get_string()' - Get a string setting from the CUPS preferences.
  1366 | //
  1367 |
  1368 | static int				// O - 1 if set, 0 otherwise
  1369 | cups_apple_get_string(
  1370 |     CFStringRef key,			// I - Key (name)
  1371 |     char        *value,			// O - String value
  1372 |     size_t      valsize)		// I - Size of value buffer
  1373 | {
  1374 |   CFStringRef	sval;			// String value
  1375 |
  1376 |
  1377 |   if ((sval = CFPreferencesCopyAppValue(key, kCUPSPrintingPrefs)) != NULL)
  1378 |   {
  1379 |     Boolean result = CFStringGetCString(sval, value, (CFIndex)valsize, kCFStringEncodingUTF8);
  1380 |
  1381 |     CFRelease(sval);
  1382 |
  1383 |     if (result)
  1384 |       return (1);
  1385 |   }
  1386 |
  1387 |   return (0);
  1388 | }
  1389 | #endif // __APPLE__
  1390 |
  1391 |
  1392 | //
  1393 | // 'cups_boolean_value()' - Convert a string to a boolean value.
  1394 | //
  1395 |
  1396 | static int				// O - Boolean value
  1397 | cups_boolean_value(const char *value)	// I - String value
  1398 | {
  1399 |   return (!_cups_strcasecmp(value, "yes") || !_cups_strcasecmp(value, "on") || !_cups_strcasecmp(value, "true"));
  1400 | }
  1401 |
  1402 |
  1403 | //
  1404 | // 'cups_finalize_client_conf()' - Finalize client.conf values.
  1405 | //
  1406 |
  1407 | static void
  1408 | cups_finalize_client_conf(
  1409 |     _cups_client_conf_t *cc)		// I - client.conf values
  1410 | {
  1411 |   const char	*value;			// Environment variable
  1412 |
  1413 |
  1414 |   if ((value = getenv("CUPS_BROWSE_DOMAINS")) != NULL)
> 1415 |     cups_set_browse_domains(cc, value);
  1416 |
  1417 |   if ((value = getenv("CUPS_FILTER_LOCATION")) != NULL)
  1418 |     cups_set_filter_location(cc, value);
  1419 |
  1420 |   if ((value = getenv("CUPS_FILTER_TYPE")) != NULL)
  1421 |     cups_set_filter_type(cc, value);
  1422 |
  1423 |   if ((value = getenv("CUPS_TRUSTFIRST")) != NULL)
  1424 |     cc->trust_first = cups_boolean_value(value);
  1425 |
  1426 |   if ((value = getenv("CUPS_ANYROOT")) != NULL)
  1427 |     cc->any_root = cups_boolean_value(value);
  1428 |
  1429 |   if ((value = getenv("CUPS_ENCRYPTION")) != NULL)
  1430 |     cups_set_encryption(cc, value);
  1431 |
  1432 |   if ((value = getenv("CUPS_EXPIREDCERTS")) != NULL)
  1433 |     cc->expired_certs = cups_boolean_value(value);
  1434 |
  1435 | #ifdef HAVE_GSSAPI
  1436 |   if ((value = getenv("CUPS_GSSSERVICENAME")) != NULL)
  1437 |     cups_set_gss_service_name(cc, value);
  1438 | #endif // HAVE_GSSAPI
  1439 |
  1440 |   if ((value = getenv("CUPS_SERVER")) != NULL)
  1441 |     cups_set_server_name(cc, value);
  1442 |
  1443 |   if ((value = getenv("CUPS_USER")) != NULL)
  1444 |     cups_set_user(cc, value);
  1445 |
  1446 |   if ((value = getenv("CUPS_VALIDATECERTS")) != NULL)
  1447 |     cc->validate_certs = cups_boolean_value(value);
  1448 |
  1449 |   // Then apply defaults for those values that haven't been set...
  1450 |   if (cc->trust_first < 0)
  1451 |     cc->trust_first = 1;
  1452 |
  1453 |   if (cc->any_root < 0)
  1454 |     cc->any_root = 1;
  1455 |
  1456 |   if (cc->encryption == (http_encryption_t)-1)
  1457 |     cc->encryption = HTTP_ENCRYPTION_IF_REQUESTED;
  1458 |
  1459 |   if (cc->expired_certs < 0)
  1460 |     cc->expired_certs = 0;
  1461 |
  1462 | #ifdef HAVE_GSSAPI
  1463 |   if (!cc->gss_service_name[0])
  1464 |     cups_set_gss_service_name(cc, CUPS_DEFAULT_GSSSERVICENAME);
  1465 | #endif // HAVE_GSSAPI
  1466 |
  1467 |   if (!cc->server_name[0])
  1468 |   {
  1469 |     // If we are compiled with domain socket support, only use the
  1470 |     // domain socket if it exists and has the right permissions...
  1471 | #if defined(__APPLE__) && !TARGET_OS_OSX
  1472 |     cups_set_server_name(cc, "/private/var/run/printd");
  1473 |
  1474 | #else
  1475 | #  ifdef CUPS_DEFAULT_DOMAINSOCKET
  1476 |     if (!access(CUPS_DEFAULT_DOMAINSOCKET, R_OK))
  1477 |       cups_set_server_name(cc, CUPS_DEFAULT_DOMAINSOCKET);
  1478 |     else
  1479 | #  endif // CUPS_DEFAULT_DOMAINSOCKET
  1480 |     cups_set_server_name(cc, "localhost");
  1481 | #endif // __APPLE__ && !TARGET_OS_OSX
  1482 |   }
  1483 |
  1484 |   if (!cc->user[0])
  1485 |   {
  1486 | #ifdef _WIN32
  1487 |     // Get the current user name from the OS...
  1488 |     DWORD	size;				// Size of string
  1489 |
  1490 |     size = sizeof(cc->user);
  1491 |     if (!GetUserNameA(cc->user, &size))
  1492 | #else
  1493 |     // Try the USER environment variable as the default username...
  1494 |     const char *envuser = getenv("USER");	// Default username
  1495 |     struct passwd pw;				// Account information
  1496 |     struct passwd *result = NULL;		// Auxiliary pointer
  1497 |     _cups_globals_t *cg = _cupsGlobals();	// Pointer to library globals
  1498 |
  1499 |     if (envuser)
  1500 |     {
  1501 |       // Validate USER matches the current UID, otherwise don't allow it to
  1502 |       // override things...  This makes sure that printing after doing su
  1503 |       // or sudo records the correct username.
  1504 |       getpwnam_r(envuser, &pw, cg->pw_buf, PW_BUF_SIZE, &result);
  1505 |       if (result && pw.pw_uid != getuid())
  1506 |         result = NULL;
  1507 |     }
  1508 |
  1509 |     if (!result)
  1510 |       getpwuid_r(getuid(), &pw, cg->pw_buf, PW_BUF_SIZE, &result);
  1511 |
  1512 |     if (result)
  1513 |       cupsCopyString(cc->user, pw.pw_name, sizeof(cc->user));
  1514 |     else
  1515 | #endif // _WIN32

Reach line at /src/cups/cups/usersys.c:1415 (observed count 0).


Reach line at /src/cups/cups/file.c:1436 (observed count 0).


   80 | static void ddsrt_cond_init_impl (pthread_cond_t *cond, enum ddsrt_clockid clockid)
   81 | {
   82 |   pthread_condattr_t condattr;
   83 |   pthread_condattr_init (&condattr);
   84 | #ifdef DDSRT_HAVE_CONDATTR_SETCLOCK
   85 |   ddsrt_condattr_setclock (&condattr, clockid);
   86 | #else
   87 |   (void) clockid;
   88 | #endif
   89 |   if (pthread_cond_init (cond, &condattr) != 0)
   90 |     abort ();
   91 |   pthread_condattr_destroy (&condattr);
   92 | }
   93 |
   94 | void ddsrt_cond_init (ddsrt_cond_t *cond)
   95 | {
   96 |   pthread_cond_init (&cond->cond, NULL);
   97 | }
   98 |
   99 | void ddsrt_cond_wctime_init (ddsrt_cond_wctime_t *cond)
  100 | {
  101 |   ddsrt_cond_init_impl (&cond->cond, DDSRT_CLOCK_WALLCLOCK);
  102 | }
  103 |
  104 | void ddsrt_cond_mtime_init (ddsrt_cond_mtime_t *cond)
  105 | {
  106 |   ddsrt_cond_init_impl (&cond->cond, DDSRT_CLOCK_MONOTONIC);
  107 | }
  108 |
  109 | void ddsrt_cond_etime_init (ddsrt_cond_etime_t *cond)
  110 | {
  111 |   ddsrt_cond_init_impl (&cond->cond, DDSRT_CLOCK_ELAPSED);
  112 | }
  113 |
  114 | void ddsrt_cond_destroy (ddsrt_cond_t *cond)
  115 | {
  116 |   if (pthread_cond_destroy (&cond->cond) != 0)
  117 |     abort ();
  118 | }
  119 |
  120 | void ddsrt_cond_wctime_destroy (ddsrt_cond_wctime_t *cond)
  121 | {
  122 |   if (pthread_cond_destroy (&cond->cond) != 0)
  123 |     abort ();
  124 | }
  125 |
  126 | void ddsrt_cond_mtime_destroy (ddsrt_cond_mtime_t *cond)
  127 | {
  128 |   if (pthread_cond_destroy (&cond->cond) != 0)
  129 |     abort ();
  130 | }
  131 |
  132 | void ddsrt_cond_etime_destroy (ddsrt_cond_etime_t *cond)
  133 | {
  134 |   if (pthread_cond_destroy (&cond->cond) != 0)
  135 |     abort ();
  136 | }
  137 |
  138 | void ddsrt_cond_wait (ddsrt_cond_t *cond, ddsrt_mutex_t *mutex)
  139 | {
  140 |   if (pthread_cond_wait (&cond->cond, &mutex->mutex) != 0)
  141 |     abort ();
  142 | }
  143 |
  144 | void ddsrt_cond_wctime_wait (ddsrt_cond_wctime_t *cond, ddsrt_mutex_t *mutex)
  145 | {
  146 |   if (pthread_cond_wait (&cond->cond, &mutex->mutex) != 0)
  147 |     abort ();
  148 | }
  149 |
  150 | void ddsrt_cond_mtime_wait (ddsrt_cond_mtime_t *cond, ddsrt_mutex_t *mutex)
  151 | {
  152 |   if (pthread_cond_wait (&cond->cond, &mutex->mutex) != 0)
  153 |     abort ();
  154 | }
  155 |
  156 | void ddsrt_cond_etime_wait (ddsrt_cond_etime_t *cond, ddsrt_mutex_t *mutex)
  157 | {
  158 |   if (pthread_cond_wait (&cond->cond, &mutex->mutex) != 0)
  159 |     abort ();
  160 | }
  161 |
  162 | static bool ddsrt_cond_waituntil_impl (pthread_cond_t *cond, pthread_mutex_t *mutex, int64_t abstime)
  163 | {
  164 |   struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
  165 |   if (abstime == DDS_NEVER) {
  166 |     if (pthread_cond_wait(cond, mutex) != 0)
  167 |       abort();
  168 |     return true;
  169 |   }
  170 |   if (abstime > 0) {
  171 |     ts.tv_sec = (time_t) (abstime / DDS_NSECS_IN_SEC);
  172 |     ts.tv_nsec = (suseconds_t) (abstime % DDS_NSECS_IN_SEC);
  173 |   }
  174 |   switch (pthread_cond_timedwait (cond, mutex, &ts)) {
  175 |     case 0:
  176 |       return true;
  177 |     case ETIMEDOUT:
  178 |       return false;
  179 |     default:
> 180 |       break;
  181 |   }
  182 |   abort();
  183 |   return false;
  184 | }
  185 |
  186 | bool ddsrt_cond_wctime_waituntil (ddsrt_cond_wctime_t *cond, ddsrt_mutex_t *mutex, ddsrt_wctime_t abstime)
  187 | {
  188 |   return ddsrt_cond_waituntil_impl(&cond->cond, &mutex->mutex, abstime.v);
  189 | }
  190 |
  191 | #ifdef DDSRT_HAVE_CONDATTR_SETCLOCK
  192 | bool ddsrt_cond_mtime_waituntil (ddsrt_cond_mtime_t *cond, ddsrt_mutex_t *mutex, ddsrt_mtime_t abstime)
  193 | {
  194 |   return ddsrt_cond_waituntil_impl(&cond->cond, &mutex->mutex, abstime.v);
  195 | }
  196 |
  197 | bool ddsrt_cond_etime_waituntil (ddsrt_cond_etime_t *cond, ddsrt_mutex_t *mutex, ddsrt_etime_t abstime)
  198 | {
  199 |   return ddsrt_cond_waituntil_impl(&cond->cond, &mutex->mutex, abstime.v);
  200 | }
  201 | #else
  202 | static bool ddsrt_cond_waituntil_clockconv_impl (pthread_cond_t *cond, pthread_mutex_t *mutex, int64_t abstime, int64_t tnow_wc, int64_t tnow_src)
  203 | {
  204 |   if (abstime == DDS_NEVER)
  205 |     return ddsrt_cond_waituntil_impl (cond, mutex, abstime);
  206 |   else if (abstime < tnow_src)
  207 |     return false;
  208 |   else
  209 |     return ddsrt_cond_waituntil_impl (cond, mutex, ddsrt_time_add_duration (tnow_wc, abstime - tnow_src));
  210 | }
  211 |
  212 | bool ddsrt_cond_mtime_waituntil (ddsrt_cond_mtime_t *cond, ddsrt_mutex_t *mutex, ddsrt_mtime_t abstime)
  213 | {
  214 |   const ddsrt_mtime_t tnow_m = ddsrt_time_monotonic ();
  215 |   const ddsrt_wctime_t tnow_wc = ddsrt_time_wallclock ();
  216 |   return ddsrt_cond_waituntil_clockconv_impl (&cond->cond, &mutex->mutex, abstime.v, tnow_wc.v, tnow_m.v);
  217 | }
  218 |
  219 | bool ddsrt_cond_etime_waituntil (ddsrt_cond_etime_t *cond, ddsrt_mutex_t *mutex, ddsrt_etime_t abstime)
  220 | {
  221 |   const ddsrt_etime_t tnow_e = ddsrt_time_elapsed ();
  222 |   const ddsrt_wctime_t tnow_wc = ddsrt_time_wallclock ();
  223 |   return ddsrt_cond_waituntil_clockconv_impl (&cond->cond, &mutex->mutex, abstime.v, tnow_wc.v, tnow_e.v);
  224 | }
  225 | #endif
  226 |
  227 | void ddsrt_cond_signal (ddsrt_cond_t *cond)
  228 | {
  229 |   if (pthread_cond_signal (&cond->cond) != 0)
  230 |     abort ();
  231 | }
  232 |
  233 | void ddsrt_cond_wctime_signal (ddsrt_cond_wctime_t *cond)
  234 | {
  235 |   if (pthread_cond_signal (&cond->cond) != 0)
  236 |     abort ();
  237 | }
  238 |
  239 | void ddsrt_cond_mtime_signal (ddsrt_cond_mtime_t *cond)
  240 | {
  241 |   if (pthread_cond_signal (&cond->cond) != 0)
  242 |     abort ();
  243 | }
  244 |
  245 | void ddsrt_cond_etime_signal (ddsrt_cond_etime_t *cond)
  246 | {
  247 |   if (pthread_cond_signal (&cond->cond) != 0)
  248 |     abort ();
  249 | }
  250 |
  251 | void ddsrt_cond_broadcast (ddsrt_cond_t *cond)
  252 | {
  253 |   if (pthread_cond_broadcast (&cond->cond) != 0)
  254 |     abort ();
  255 | }
  256 |
  257 | void ddsrt_cond_wctime_broadcast (ddsrt_cond_wctime_t *cond)
  258 | {
  259 |   if (pthread_cond_broadcast (&cond->cond) != 0)
  260 |     abort ();
  261 | }
  262 |
  263 | void ddsrt_cond_mtime_broadcast (ddsrt_cond_mtime_t *cond)
  264 | {
  265 |   if (pthread_cond_broadcast (&cond->cond) != 0)
  266 |     abort ();
  267 | }
  268 |
  269 | void ddsrt_cond_etime_broadcast (ddsrt_cond_etime_t *cond)
  270 | {
  271 |   if (pthread_cond_broadcast (&cond->cond) != 0)
  272 |     abort ();
  273 | }
  274 |
  275 | void ddsrt_rwlock_init (ddsrt_rwlock_t *rwlock)
  276 | {
  277 | #if __SunOS_5_6
  278 |   if (pthread_mutex_init (&rwlock->rwlock, NULL) != 0)
  279 |     abort ();
  280 | #else

Reach line at /src/cyclonedds/src/ddsrt/src/sync/posix/sync.c:180 (observed count 0).


  3284 | ddsrt_nonnull_all
  3285 | static const uint32_t *dds_stream_skip_default (char * restrict data, const struct dds_cdrstream_allocator *allocator, const uint32_t *ops, enum sample_data_state sample_state)
  3286 | {
  3287 |   uint32_t insn;
  3288 |   while ((insn = *ops) != DDS_OP_RTS)
  3289 |   {
  3290 |     switch (DDS_OP (insn))
  3291 |     {
  3292 |       case DDS_OP_ADR: {
  3293 |         ops = dds_stream_skip_adr_default (insn, data, allocator, ops, sample_state);
  3294 |         break;
  3295 |       }
  3296 |       case DDS_OP_JSR: {
  3297 |         (void) dds_stream_skip_default (data, allocator, ops + DDS_OP_JUMP (insn), sample_state);
  3298 |         ops++;
  3299 |         break;
  3300 |       }
  3301 |       case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: case DDS_OP_MID:
  3302 |         abort ();
  3303 |         break;
  3304 |       case DDS_OP_DLC:
  3305 |         ops = dds_stream_skip_delimited_default (data, allocator, ops, sample_state);
  3306 |         break;
  3307 |       case DDS_OP_PLC:
  3308 |         ops = dds_stream_skip_pl_default (data, allocator, ops, sample_state);
  3309 |         break;
  3310 |     }
  3311 |   }
  3312 |   return ops;
  3313 | }
  3314 |
  3315 | ddsrt_attribute_warn_unused_result ddsrt_nonnull_all
  3316 | static const uint32_t *dds_stream_read_delimited (dds_istream_t *is, char * restrict data, const struct dds_cdrstream_allocator *allocator, const uint32_t *ops, enum cdr_data_kind cdr_kind, enum sample_data_state sample_state)
  3317 | {
  3318 |   uint32_t delimited_offs = is->m_index, insn, delimited_sz = is->m_size - is->m_index;
  3319 |   ops++; // skip DLC op
  3320 |   while ((insn = *ops) != DDS_OP_RTS)
  3321 |   {
  3322 |     switch (DDS_OP (insn))
  3323 |     {
  3324 |       case DDS_OP_ADR: {
  3325 |         /* skip fields that are not in serialized data for appendable type */
  3326 |         ops = (is->m_index - delimited_offs < delimited_sz) ? dds_stream_read_adr (insn, is, data, allocator, ops, false, cdr_kind, sample_state) : dds_stream_skip_adr_default (insn, data, allocator, ops, sample_state);
  3327 |         break;
  3328 |       }
  3329 |       case DDS_OP_JSR: {
  3330 |         (void) dds_stream_read_impl (is, data, allocator, ops + DDS_OP_JUMP (insn), false, cdr_kind, sample_state);
  3331 |         ops++;
  3332 |         break;
  3333 |       }
  3334 |       case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_DLC: case DDS_OP_PLC: case DDS_OP_PLM: case DDS_OP_MID: {
  3335 |         abort ();
  3336 |         break;
  3337 |       }
  3338 |     }
  3339 |   }
  3340 |   /* Skip remainder of serialized data for this appendable type */
  3341 |   if (delimited_sz > is->m_index - delimited_offs)
  3342 |     is->m_index += delimited_sz - (is->m_index - delimited_offs);
  3343 |   return ops;
  3344 | }
  3345 |
  3346 | ddsrt_nonnull_all
  3347 | static bool dds_stream_read_pl_member (dds_istream_t *is, char * restrict data, const struct dds_cdrstream_allocator *allocator, uint32_t m_id, const uint32_t *ops, enum cdr_data_kind cdr_kind, enum sample_data_state sample_state)
  3348 | {
  3349 |   uint32_t insn, ops_csr = 0;
  3350 |   bool found = false;
  3351 |
  3352 |   /* FIXME: continue finding the member in the ops member list starting from the last
  3353 |       found one, because in many cases the members will be in the data sequentially */
  3354 |   while (!found && (insn = ops[ops_csr]) != DDS_OP_RTS)
  3355 |   {
  3356 |     assert (DDS_OP (insn) == DDS_OP_PLM);
  3357 |     uint32_t flags = DDS_PLM_FLAGS (insn);
  3358 |     const uint32_t *plm_ops = ops + ops_csr + DDS_OP_ADR_PLM (insn);
  3359 |     if (flags & DDS_OP_FLAG_BASE)
  3360 |     {
  3361 |       assert (DDS_OP (plm_ops[0]) == DDS_OP_PLC);
  3362 |       plm_ops++; /* skip PLC to go to first PLM from base type */
  3363 |       found = dds_stream_read_pl_member (is, data, allocator, m_id, plm_ops, cdr_kind, sample_state);
  3364 |     }
  3365 |     else if (ops[ops_csr + 1] == m_id)
  3366 |     {
  3367 |       (void) dds_stream_read_impl (is, data, allocator, plm_ops, true, cdr_kind, sample_state);
  3368 |       found = true;
  3369 |       break;
  3370 |     }
  3371 |     ops_csr += 2;
  3372 |   }
  3373 |   return found;
  3374 | }
  3375 |
  3376 | ddsrt_attribute_warn_unused_result ddsrt_nonnull_all
  3377 | static const uint32_t *dds_stream_read_xcdr1_pl (dds_istream_t *is, char * restrict data, const struct dds_cdrstream_allocator *allocator, const uint32_t *ops, enum cdr_data_kind cdr_kind, enum sample_data_state sample_state)
  3378 | {
  3379 |   /* skip PLC op */
  3380 |   ops++;
  3381 |
  3382 |   /* default-initialize all members
  3383 |       FIXME: optimize so that only members not in received data are initialized */
> 3384 |   dds_stream_skip_pl_memberlist_default (data, allocator, ops, sample_state);
  3385 |
  3386 |   uint32_t param_mid, param_len;
  3387 |   while (stream_read_xcdr1_paramheader (is, &param_mid, &param_len))
  3388 |   {
  3389 |     // Move buffer in temporary istream `is1` to start of parameter value and
  3390 |     // set size to param length, so that alignment is reset to 0
  3391 |     dds_istream_t is1 = *is;
  3392 |     is1.m_buffer += is1.m_index;
  3393 |     is1.m_index = 0;
  3394 |     is1.m_size = param_len;
  3395 |
  3396 |     // find member and deserialize
  3397 |     (void) dds_stream_read_pl_member (&is1, data, allocator, param_mid, ops, cdr_kind, sample_state);
  3398 |
  3399 |     // forward index in CDR by param_len if found, and also in case member not known
  3400 |     is->m_index += param_len;
  3401 |   }
  3402 |
  3403 |   /* skip all PLM-memberid pairs */
  3404 |   while (ops[0] != DDS_OP_RTS)
  3405 |     ops += 2;
  3406 |
  3407 |   return ops;
  3408 | }
  3409 |
  3410 | ddsrt_attribute_warn_unused_result ddsrt_nonnull_all
  3411 | static const uint32_t *dds_stream_read_xcdr2_pl (dds_istream_t *is, char * restrict data, const struct dds_cdrstream_allocator *allocator, const uint32_t *ops, enum cdr_data_kind cdr_kind, enum sample_data_state sample_state)
  3412 | {
  3413 |   /* skip PLC op */
  3414 |   ops++;
  3415 |
  3416 |   /* default-initialize all members
  3417 |       FIXME: optimize so that only members not in received data are initialized */
  3418 |   dds_stream_skip_pl_memberlist_default (data, allocator, ops, sample_state);
  3419 |
  3420 |   /* read DHEADER */
  3421 |   uint32_t pl_sz = dds_is_get4 (is), pl_offs = is->m_index;
  3422 |   while (is->m_index - pl_offs < pl_sz)
  3423 |   {
  3424 |     /* read EMHEADER and next_int */
  3425 |     uint32_t em_hdr = dds_is_get4 (is);
  3426 |     uint32_t lc = EMHEADER_LENGTH_CODE (em_hdr), m_id = EMHEADER_MEMBERID (em_hdr), msz;
  3427 |     switch (lc)
  3428 |     {
  3429 |       case LENGTH_CODE_1B: case LENGTH_CODE_2B: case LENGTH_CODE_4B: case LENGTH_CODE_8B:
  3430 |         msz = 1u << lc;
  3431 |         break;
  3432 |       case LENGTH_CODE_NEXTINT:
  3433 |         /* read NEXTINT */
  3434 |         msz = dds_is_get4 (is);
  3435 |         break;
  3436 |       case LENGTH_CODE_ALSO_NEXTINT: case LENGTH_CODE_ALSO_NEXTINT4: case LENGTH_CODE_ALSO_NEXTINT8:
  3437 |         /* length is part of serialized data */
  3438 |         msz = dds_is_peek4 (is);
  3439 |         if (lc > LENGTH_CODE_ALSO_NEXTINT)
  3440 |           msz <<= (lc - 4);
  3441 |         break;
  3442 |       default:
  3443 |         abort ();
  3444 |         break;
  3445 |     }
  3446 |
  3447 | #ifndef NDEBUG
  3448 |     /* next field starts here (length embedded in member does not include it's own 4 bytes): */
  3449 |     const uint32_t next_off = is->m_index + msz + ((lc >= LENGTH_CODE_ALSO_NEXTINT) ? 4 : 0);
  3450 | #endif
  3451 |     /* find member and deserialize */
  3452 |     if (!dds_stream_read_pl_member (is, data, allocator, m_id, ops, cdr_kind, sample_state))
  3453 |     {
  3454 |       is->m_index += msz;
  3455 |       if (lc >= LENGTH_CODE_ALSO_NEXTINT)
  3456 |         is->m_index += 4; /* length embedded in member does not include it's own 4 bytes */
  3457 |     }
  3458 |     assert (next_off == is->m_index);
  3459 |   }
  3460 |
  3461 |   /* skip all PLM-memberid pairs */
  3462 |   while (ops[0] != DDS_OP_RTS)
  3463 |     ops += 2;
  3464 |
  3465 |   return ops;
  3466 | }
  3467 |
  3468 | static const uint32_t *dds_stream_read_impl (dds_istream_t *is, char * restrict data, const struct dds_cdrstream_allocator *allocator, const uint32_t *ops, bool is_mutable_member, enum cdr_data_kind cdr_kind, enum sample_data_state sample_state)
  3469 | {
  3470 |   uint32_t insn;
  3471 |   while ((insn = *ops) != DDS_OP_RTS)
  3472 |   {
  3473 |     switch (DDS_OP (insn))
  3474 |     {
  3475 |       case DDS_OP_ADR:
  3476 |         ops = dds_stream_read_adr (insn, is, data, allocator, ops, is_mutable_member, cdr_kind, sample_state);
  3477 |         break;
  3478 |       case DDS_OP_JSR:
  3479 |         (void) dds_stream_read_impl (is, data, allocator, ops + DDS_OP_JUMP (insn), is_mutable_member, cdr_kind, sample_state);
  3480 |         ops++;
  3481 |         break;
  3482 |       case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: case DDS_OP_MID:
  3483 |         abort ();
  3484 |         break;

Reach line at /src/cyclonedds/src/core/cdr/src/dds_cdrstream.c:3384 (observed count 0).


  1476 |     if (ret == DDS_RETCODE_OK)
  1477 |     {
  1478 |       ddsi_xt_type_fini (gv, xt, false);
  1479 |       ret = ret_validate;
  1480 |     }
  1481 |     GVWARNING ("type " PTYPEIDFMT ": ddsi_xt_type_add_typeobj with invalid type object\n", PTYPEID (xt->id.x));
  1482 |   }
  1483 |
  1484 |   return ret;
  1485 | }
  1486 |
  1487 | dds_return_t ddsi_xt_type_init_impl (struct ddsi_domaingv *gv, struct xt_type *xt, const struct DDS_XTypes_TypeIdentifier *ti, const struct DDS_XTypes_TypeObject *to)
  1488 | {
  1489 |   assert (xt);
  1490 |   assert (ti);
  1491 |   dds_return_t ret = DDS_RETCODE_OK;
  1492 |
  1493 |   ddsi_typeid_copy_impl (&xt->id.x, ti);
  1494 |   if (ti->_d <= DDS_XTypes_TK_STRING16)
  1495 |   {
  1496 |     if (to != NULL)
  1497 |       return DDS_RETCODE_BAD_PARAMETER;
  1498 |     xt->_d = ti->_d;
  1499 |   }
  1500 |   else
  1501 |   {
  1502 |     switch (ti->_d)
  1503 |     {
  1504 |       case DDS_XTypes_TI_STRING8_SMALL:
  1505 |         xt->_d = DDS_XTypes_TK_STRING8;
  1506 |         xt->_u.str8.bound = (DDS_XTypes_LBound) ti->_u.string_sdefn.bound;
  1507 |         break;
  1508 |       case DDS_XTypes_TI_STRING8_LARGE:
  1509 |         xt->_d = DDS_XTypes_TK_STRING8;
  1510 |         xt->_u.str8.bound = ti->_u.string_ldefn.bound;
  1511 |         break;
  1512 |       case DDS_XTypes_TI_STRING16_SMALL:
  1513 |         xt->_d = DDS_XTypes_TK_STRING16;
  1514 |         xt->_u.str16.bound = (DDS_XTypes_LBound) ti->_u.string_sdefn.bound;
  1515 |         break;
  1516 |       case DDS_XTypes_TI_STRING16_LARGE:
  1517 |         xt->_d = DDS_XTypes_TK_STRING16;
  1518 |         xt->_u.str16.bound = ti->_u.string_ldefn.bound;
  1519 |         break;
  1520 |       case DDS_XTypes_TI_PLAIN_SEQUENCE_SMALL:
  1521 |         xt->_d = DDS_XTypes_TK_SEQUENCE;
  1522 |         if ((ret = ddsi_type_register_dep (gv, &xt->id, &xt->_u.seq.c.element_type, ti->_u.seq_sdefn.element_identifier)) != DDS_RETCODE_OK)
  1523 |           goto err;
  1524 |         xt->_u.seq.bound = (DDS_XTypes_LBound) ti->_u.seq_sdefn.bound;
  1525 |         xt_collection_common_init (&xt->_u.seq.c, &ti->_u.seq_sdefn.header);
  1526 |         break;
  1527 |       case DDS_XTypes_TI_PLAIN_SEQUENCE_LARGE:
  1528 |         xt->_d = DDS_XTypes_TK_SEQUENCE;
  1529 |         if ((ret = ddsi_type_register_dep (gv, &xt->id, &xt->_u.seq.c.element_type, ti->_u.seq_ldefn.element_identifier)) != DDS_RETCODE_OK)
  1530 |           goto err;
  1531 |         xt->_u.seq.bound = ti->_u.seq_ldefn.bound;
  1532 |         xt_collection_common_init (&xt->_u.seq.c, &ti->_u.seq_ldefn.header);
  1533 |         break;
  1534 |       case DDS_XTypes_TI_PLAIN_ARRAY_SMALL:
  1535 |         xt->_d = DDS_XTypes_TK_ARRAY;
  1536 |         if ((ret = ddsi_type_register_dep (gv, &xt->id, &xt->_u.array.c.element_type, ti->_u.array_sdefn.element_identifier)) != DDS_RETCODE_OK)
  1537 |           goto err;
  1538 |         xt_collection_common_init (&xt->_u.array.c, &ti->_u.array_sdefn.header);
  1539 |         xt_sbounds_to_lbounds (&xt->_u.array.bounds, &ti->_u.array_sdefn.array_bound_seq);
  1540 |         break;
  1541 |       case DDS_XTypes_TI_PLAIN_ARRAY_LARGE:
  1542 |         xt->_d = DDS_XTypes_TK_ARRAY;
  1543 |         if ((ret = ddsi_type_register_dep (gv, &xt->id, &xt->_u.array.c.element_type, ti->_u.array_ldefn.element_identifier)) != DDS_RETCODE_OK)
  1544 |           goto err;
  1545 |         xt_collection_common_init (&xt->_u.array.c, &ti->_u.array_ldefn.header);
  1546 |         xt_lbounds_dup (&xt->_u.array.bounds, &ti->_u.array_ldefn.array_bound_seq);
  1547 |         break;
  1548 |       case DDS_XTypes_TI_PLAIN_MAP_SMALL:
  1549 |         xt->_d = DDS_XTypes_TK_MAP;
  1550 |         if ((ret = ddsi_type_register_dep (gv, &xt->id, &xt->_u.map.c.element_type, ti->_u.map_sdefn.element_identifier)) != DDS_RETCODE_OK)
  1551 |           goto err;
  1552 |         xt->_u.map.bound = (DDS_XTypes_LBound) ti->_u.map_sdefn.bound;
  1553 |         xt_collection_common_init (&xt->_u.map.c, &ti->_u.map_sdefn.header);
  1554 |         if ((ret = ddsi_type_register_dep (gv, &xt->id, &xt->_u.map.key_type, ti->_u.map_sdefn.key_identifier)) != DDS_RETCODE_OK)
  1555 |         {
  1556 |           ddsi_type_unref_locked (gv, xt->_u.map.c.element_type);
  1557 |           xt->_u.map.c.element_type = NULL;
  1558 |           goto err;
  1559 |         }
  1560 |         break;
  1561 |       case DDS_XTypes_TI_PLAIN_MAP_LARGE:
  1562 |         xt->_d = DDS_XTypes_TK_MAP;
  1563 |         if ((ret = ddsi_type_register_dep (gv, &xt->id, &xt->_u.map.c.element_type, ti->_u.map_ldefn.element_identifier)) != DDS_RETCODE_OK)
  1564 |           goto err;
  1565 |         xt->_u.map.bound = (DDS_XTypes_LBound) ti->_u.map_ldefn.bound;
  1566 |         xt_collection_common_init (&xt->_u.map.c, &ti->_u.map_ldefn.header);
  1567 |         if ((ret = ddsi_type_register_dep (gv, &xt->id, &xt->_u.map.key_type, ti->_u.map_ldefn.key_identifier)) != DDS_RETCODE_OK)
  1568 |         {
  1569 |           ddsi_type_unref_locked (gv, xt->_u.map.c.element_type);
  1570 |           xt->_u.map.c.element_type = NULL;
  1571 |           goto err;
  1572 |         }
  1573 |         break;
  1574 |       case DDS_XTypes_EK_MINIMAL:
  1575 |         if (to != NULL)
> 1576 |           ret = add_minimal_typeobj (gv, xt, to);
  1577 |         break;
  1578 |       case DDS_XTypes_EK_COMPLETE:
  1579 |         if (to != NULL)
  1580 |           ret = add_complete_typeobj (gv, xt, to);
  1581 |         break;
  1582 |       case DDS_XTypes_TI_STRONGLY_CONNECTED_COMPONENT:
  1583 |         xt->_d = DDS_XTypes_TI_STRONGLY_CONNECTED_COMPONENT;
  1584 |         xt->sc_component_id = ti->_u.sc_component_id;
  1585 |         break;
  1586 |       default:
  1587 |         ddsi_typeid_fini (&xt->id);
  1588 |         ret = DDS_RETCODE_UNSUPPORTED; /* not supported */
  1589 |         break;
  1590 |     }
  1591 |   }
  1592 |   if (ret != DDS_RETCODE_OK || (ret = ddsi_xt_validate (gv, xt)) != DDS_RETCODE_OK)
  1593 |   {
  1594 |     GVWARNING ("type " PTYPEIDFMT ": ddsi_xt_type_init_impl with invalid type object\n", PTYPEID (xt->id.x));
  1595 |     goto err;
  1596 |   }
  1597 |   if ((xt->kind = ddsi_typeid_kind_impl (ti)) == DDSI_TYPEID_KIND_INVALID)
  1598 |   {
  1599 |     GVWARNING ("type " PTYPEIDFMT ": ddsi_xt_type_init_impl with invalid typeid\n", PTYPEID (xt->id.x));
  1600 |     ret = DDS_RETCODE_BAD_PARAMETER;
  1601 |     goto err;
  1602 |   }
  1603 |
  1604 | err:
  1605 |   return ret;
  1606 | }
  1607 |
  1608 | dds_return_t ddsi_xt_type_init (struct ddsi_domaingv *gv, struct xt_type *xt, const ddsi_typeid_t *ti, const ddsi_typeobj_t *to)
  1609 | {
  1610 |   return ddsi_xt_type_init_impl (gv, xt, &ti->x, &to->x);
  1611 | }
  1612 |
  1613 | static void DDS_XTypes_AppliedVerbatimAnnotation_copy (struct DDS_XTypes_AppliedVerbatimAnnotation *dst, const struct DDS_XTypes_AppliedVerbatimAnnotation *src)
  1614 | {
  1615 |   assert (dst);
  1616 |   if (src)
  1617 |   {
  1618 |     ddsrt_strlcpy (dst->placement, src->placement, sizeof (dst->placement));
  1619 |     ddsrt_strlcpy (dst->language, src->language, sizeof (dst->language));
  1620 |     dst->text = ddsrt_strdup (src->text);
  1621 |   }
  1622 | }
  1623 |
  1624 | static void DDS_XTypes_AppliedBuiltinTypeAnnotations_copy (struct DDS_XTypes_AppliedBuiltinTypeAnnotations *dst, const struct DDS_XTypes_AppliedBuiltinTypeAnnotations *src)
  1625 | {
  1626 |   if (src)
  1627 |   {
  1628 |     dst->verbatim = calloc (1, sizeof (*dst->verbatim));
  1629 |     DDS_XTypes_AppliedVerbatimAnnotation_copy (dst->verbatim, src->verbatim);
  1630 |   }
  1631 | }
  1632 |
  1633 | static void DDS_XTypes_AppliedAnnotationParameter_copy (struct DDS_XTypes_AppliedAnnotationParameter *dst, const struct DDS_XTypes_AppliedAnnotationParameter *src)
  1634 | {
  1635 |   if (src)
  1636 |   {
  1637 |     memcpy (dst->paramname_hash, src->paramname_hash, sizeof (dst->paramname_hash));
  1638 |     dst->value = src->value;
  1639 |   }
  1640 | }
  1641 |
  1642 | static void DDS_XTypes_AppliedAnnotationParameterSeq_copy (struct DDS_XTypes_AppliedAnnotationParameterSeq **dst, const struct DDS_XTypes_AppliedAnnotationParameterSeq *src)
  1643 | {
  1644 |   if (src)
  1645 |   {
  1646 |     (*dst) = ddsrt_calloc (1, sizeof (**dst));
  1647 |     (*dst)->_maximum = src->_maximum;
  1648 |     (*dst)->_length = src->_length;
  1649 |     (*dst)->_buffer = ddsrt_calloc (src->_length, sizeof (*(*dst)->_buffer));
  1650 |     for (uint32_t n = 0; n < src->_length; n++)
  1651 |       DDS_XTypes_AppliedAnnotationParameter_copy (&(*dst)->_buffer[n], &src->_buffer[n]);
  1652 |     (*dst)->_release = true;
  1653 |   }
  1654 | }
  1655 |
  1656 | static void DDS_XTypes_AppliedAnnotation_copy (struct DDS_XTypes_AppliedAnnotation *dst, const struct DDS_XTypes_AppliedAnnotation *src)
  1657 | {
  1658 |   if (src)
  1659 |   {
  1660 |     ddsi_typeid_copy_impl (&dst->annotation_typeid, &src->annotation_typeid);
  1661 |     DDS_XTypes_AppliedAnnotationParameterSeq_copy (&dst->param_seq, src->param_seq);
  1662 |   }
  1663 | }
  1664 |
  1665 | static void DDS_XTypes_AppliedAnnotationSeq_copy (struct DDS_XTypes_AppliedAnnotationSeq *dst, const struct DDS_XTypes_AppliedAnnotationSeq *src)
  1666 | {
  1667 |   if (src)
  1668 |   {
  1669 |     dst->_maximum = src->_maximum;
  1670 |     dst->_length = src->_length;
  1671 |     dst->_buffer = ddsrt_calloc (src->_length, sizeof (*dst->_buffer));
  1672 |     for (uint32_t n = 0; n < src->_length; n++)
  1673 |       DDS_XTypes_AppliedAnnotation_copy (&dst->_buffer[n], &src->_buffer[n]);
  1674 |     dst->_release = true;
  1675 |   }
  1676 | }

Reach line at /src/cyclonedds/src/core/ddsi/src/ddsi_typewrap.c:1576 (observed count 0).


   47 |   struct ddsi_serdata_pserop *d = (struct ddsi_serdata_pserop *) dcmn;
   48 |   const struct ddsi_sertype_pserop *tp = (const struct ddsi_sertype_pserop *) d->c.type;
   49 |   if (d->c.kind == SDK_DATA)
   50 |     ddsi_plist_fini_generic (d->sample, tp->ops, true);
   51 |   if (d->sample)
   52 |     ddsrt_free (d->sample);
   53 |   ddsrt_free (d);
   54 | }
   55 |
   56 | static struct ddsi_serdata_pserop *serdata_pserop_new (const struct ddsi_sertype_pserop *tp, enum ddsi_serdata_kind kind, size_t size, const void *cdr_header)
   57 | {
   58 |   /* FIXME: check whether this really is the correct maximum: offsets are relative
   59 |      to the CDR header, but there are also some places that use a serdata as-if it
   60 |      were a stream, and those use offsets (m_index) relative to the start of the
   61 |      serdata */
   62 |   assert (kind != SDK_EMPTY);
   63 |   if (size < 4 || size > UINT32_MAX - offsetof (struct ddsi_serdata_pserop, identifier))
   64 |     return NULL;
   65 |   const uint16_t *hdrsrc = cdr_header;
   66 |   if (hdrsrc[0] != DDSI_RTPS_CDR_LE && hdrsrc[0] != DDSI_RTPS_CDR_BE)
   67 |     return NULL;
   68 |   struct ddsi_serdata_pserop *d = ddsrt_malloc (sizeof (*d) + size);
   69 |   if (d == NULL)
   70 |     return NULL;
   71 |   ddsi_serdata_init (&d->c, &tp->c, kind);
   72 |   d->keyless = (tp->ops_key == NULL);
   73 |   d->pos = 0;
   74 |   d->size = (uint32_t) size;
   75 |   d->identifier = hdrsrc[0];
   76 |   d->options = hdrsrc[1];
   77 |   if (kind == SDK_KEY && d->keyless)
   78 |     d->sample = NULL;
   79 |   else if ((d->sample = ddsrt_malloc ((kind == SDK_DATA) ? tp->memsize : 16)) == NULL)
   80 |   {
   81 |     ddsrt_free (d);
   82 |     return NULL;
   83 |   }
   84 |   return d;
   85 | }
   86 |
   87 | static struct ddsi_serdata *serdata_pserop_fix (const struct ddsi_sertype_pserop *tp, struct ddsi_serdata_pserop *d)
   88 | {
   89 |   const bool needs_bswap = !DDSI_RTPS_CDR_ENC_IS_NATIVE (d->identifier);
   90 |   const enum ddsi_pserop *ops = (d->c.kind == SDK_DATA) ? tp->ops : tp->ops_key;
   91 |   d->c.hash = tp->c.serdata_basehash;
   92 |   if (ops != NULL)
   93 |   {
   94 |     if (ddsi_plist_deser_generic (d->sample, d->data, d->pos, needs_bswap, (d->c.kind == SDK_DATA) ? tp->ops : tp->ops_key) < 0)
   95 |     {
   96 |       ddsrt_free (d->sample);
   97 |       ddsrt_free (d);
   98 |       return NULL;
   99 |     }
  100 |     if (tp->ops_key)
  101 |     {
  102 |       assert (d->pos >= 16 && tp->memsize >= 16);
  103 |       d->c.hash ^= ddsrt_mh3 (d->sample, 16, 0);
  104 |     }
  105 |   }
  106 |   return &d->c;
  107 | }
  108 |
  109 | static struct ddsi_serdata *serdata_pserop_from_ser (const struct ddsi_sertype *tpcmn, enum ddsi_serdata_kind kind, const struct ddsi_rdata *fragchain, size_t size)
  110 |   ddsrt_nonnull_all;
  111 |
  112 | static struct ddsi_serdata *serdata_pserop_from_ser (const struct ddsi_sertype *tpcmn, enum ddsi_serdata_kind kind, const struct ddsi_rdata *fragchain, size_t size)
  113 | {
  114 |   const struct ddsi_sertype_pserop *tp = (const struct ddsi_sertype_pserop *)tpcmn;
  115 |   struct ddsi_serdata_pserop *d = serdata_pserop_new (tp, kind, size, DDSI_RMSG_PAYLOADOFF (fragchain->rmsg, DDSI_RDATA_PAYLOAD_OFF (fragchain)));
  116 |   if (d == NULL)
  117 |     return NULL;
  118 |   uint32_t off = 4; /* must skip the CDR header */
  119 |   assert (fragchain->min == 0);
  120 |   assert (fragchain->maxp1 >= off); /* CDR header must be in first fragment */
  121 |   for (const struct ddsi_rdata *frag = fragchain; frag != NULL; frag = frag->nextfrag)
  122 |   {
  123 |     assert (frag->min <= off);
  124 |     assert (frag->maxp1 <= size);
  125 |     if (frag->maxp1 > off)
  126 |     {
  127 |       /* only copy if this fragment adds data */
  128 |       const unsigned char *payload = DDSI_RMSG_PAYLOADOFF (frag->rmsg, DDSI_RDATA_PAYLOAD_OFF (frag));
  129 |       uint32_t n = frag->maxp1 - off;
  130 |       memcpy (d->data + d->pos, payload + off - frag->min, n);
  131 |       d->pos += n;
  132 |       off = frag->maxp1;
  133 |     }
  134 |   }
  135 |   return serdata_pserop_fix (tp, d);
  136 | }
  137 |
  138 | static struct ddsi_serdata *serdata_pserop_from_ser_iov (const struct ddsi_sertype *tpcmn, enum ddsi_serdata_kind kind, ddsrt_msg_iovlen_t niov, const ddsrt_iovec_t *iov, size_t size)
  139 | {
  140 |   assert (niov >= 1);
  141 |   if (iov[0].iov_len < 4)
  142 |   {
  143 |     // First fragment to short contain a full CDR header, we could handle it as long
  144 |     // as size >= 4, but it can't really happen anyway (we use this to convert an
  145 |     // already-vetted sample, so there must be a full header).  So check & reject
  146 |     // makes the most sense.
> 147 |     return NULL;
  148 |   }
  149 |   const struct ddsi_sertype_pserop *tp = (const struct ddsi_sertype_pserop *)tpcmn;
  150 |   struct ddsi_serdata_pserop *d = serdata_pserop_new (tp, kind, size, iov[0].iov_base);
  151 |   if (d == NULL)
  152 |     return NULL;
  153 |   memcpy (d->data + d->pos, (const char *) iov[0].iov_base + 4, iov[0].iov_len - 4);
  154 |   d->pos += (uint32_t) iov[0].iov_len - 4;
  155 |   for (ddsrt_msg_iovlen_t i = 1; i < niov; i++)
  156 |   {
  157 |     memcpy (d->data + d->pos, (const char *) iov[i].iov_base, iov[i].iov_len);
  158 |     d->pos += (uint32_t) iov[i].iov_len;
  159 |   }
  160 |   return serdata_pserop_fix (tp, d);
  161 | }
  162 |
  163 | static struct ddsi_serdata *serdata_pserop_from_keyhash (const struct ddsi_sertype *tpcmn, const ddsi_keyhash_t *keyhash)
  164 | {
  165 |   const struct { uint16_t identifier, options; ddsi_keyhash_t kh; } in = { DDSI_RTPS_CDR_BE, 0, *keyhash };
  166 |   const ddsrt_iovec_t iov = { .iov_base = (void *) &in, .iov_len = sizeof (in) };
  167 |   return serdata_pserop_from_ser_iov (tpcmn, SDK_KEY, 1, &iov, sizeof (in) - 4);
  168 | }
  169 |
  170 | static bool serdata_pserop_to_sample (const struct ddsi_serdata *serdata_common, void *sample, void **bufptr, void *buflim)
  171 | {
  172 |   const struct ddsi_serdata_pserop *d = (const struct ddsi_serdata_pserop *)serdata_common;
  173 |   const struct ddsi_sertype_pserop *tp = (const struct ddsi_sertype_pserop *) d->c.type;
  174 |   if (bufptr) abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */
  175 |   if (d->c.kind == SDK_KEY)
  176 |     memcpy (sample, d->sample, 16);
  177 |   else
  178 |   {
  179 |     const bool needs_bswap = !DDSI_RTPS_CDR_ENC_IS_NATIVE (d->identifier);
  180 |     dds_return_t ret = ddsi_plist_deser_generic (sample, d->data, d->pos, needs_bswap, tp->ops);
  181 |     ddsi_plist_unalias_generic (sample, tp->ops);
  182 |     assert (ret >= 0);
  183 |     (void) ret;
  184 |   }
  185 |   return true; /* FIXME: can't conversion to sample fail? */
  186 | }
  187 |
  188 | static void serdata_pserop_to_ser (const struct ddsi_serdata *serdata_common, size_t off, size_t sz, void *buf)
  189 | {
  190 |   const struct ddsi_serdata_pserop *d = (const struct ddsi_serdata_pserop *)serdata_common;
  191 |   memcpy (buf, (char *) &d->identifier + off, sz);
  192 | }
  193 |
  194 | static struct ddsi_serdata *serdata_pserop_to_ser_ref (const struct ddsi_serdata *serdata_common, size_t off, size_t sz, ddsrt_iovec_t *ref)
  195 | {
  196 |   const struct ddsi_serdata_pserop *d = (const struct ddsi_serdata_pserop *)serdata_common;
  197 |   ref->iov_base = (char *) &d->identifier + off;
  198 |   ref->iov_len = (ddsrt_iov_len_t) sz;
  199 |   return ddsi_serdata_ref (serdata_common);
  200 | }
  201 |
  202 | static void serdata_pserop_to_ser_unref (struct ddsi_serdata *serdata_common, const ddsrt_iovec_t *ref)
  203 | {
  204 |   (void) ref;
  205 |   ddsi_serdata_unref (serdata_common);
  206 | }
  207 |
  208 | static struct ddsi_serdata *serdata_pserop_from_sample (const struct ddsi_sertype *tpcmn, enum ddsi_serdata_kind kind, const void *sample)
  209 | {
  210 |   const struct ddsi_sertype_pserop *tp = (const struct ddsi_sertype_pserop *)tpcmn;
  211 |   const struct { uint16_t identifier, options; } header = { ddsi_sertype_get_native_enc_identifier (DDSI_RTPS_CDR_ENC_VERSION_1, tp->encoding_format), 0 };
  212 |   struct ddsi_serdata_pserop *d;
  213 |   if (kind == SDK_KEY && tp->ops_key == NULL)
  214 |   {
  215 |     if ((d = serdata_pserop_new (tp, kind, 0, &header)) == NULL)
  216 |       return NULL;
  217 |   }
  218 |   else
  219 |   {
  220 |     void *data;
  221 |     size_t size;
  222 |     if (ddsi_plist_ser_generic (&data, &size, sample, (kind == SDK_DATA) ? tp->ops : tp->ops_key) < 0)
  223 |       return NULL;
  224 |     const size_t size4 = (size + 3) & ~(size_t)3;
  225 |     if ((d = serdata_pserop_new (tp, kind, size4, &header)) == NULL)
  226 |     {
  227 |       ddsrt_free (data);
  228 |       return NULL;
  229 |     }
  230 |     assert (tp->ops_key == NULL || (size >= 16 && tp->memsize >= 16));
  231 |     assert (d->data != NULL); // clang static analyzer
  232 |     memcpy (d->data, data, size);
  233 |     memset (d->data + size, 0, size4 - size);
  234 |     d->pos = (uint32_t) size;
  235 |     ddsrt_free (data); // FIXME: shouldn't allocate twice & copy
  236 |     // FIXME: and then this silly thing deserialises it immediately again -- perhaps it should be a bit lazier
  237 |   }
  238 |   return serdata_pserop_fix (tp, d);
  239 | }
  240 |
  241 | static struct ddsi_serdata *serdata_pserop_to_untyped (const struct ddsi_serdata *serdata_common)
  242 | {
  243 |   const struct ddsi_serdata_pserop *d = (const struct ddsi_serdata_pserop *)serdata_common;
  244 |   const struct ddsi_sertype_pserop *tp = (const struct ddsi_sertype_pserop *)d->c.type;
  245 |   ddsrt_iovec_t iov = { .iov_base = (char *) &d->identifier, .iov_len = (ddsrt_iov_len_t) (4 + d->pos) };
  246 |   struct ddsi_serdata *dcmn_tl = serdata_pserop_from_ser_iov (&tp->c, SDK_KEY, 1, &iov, iov.iov_len);
  247 |   assert (dcmn_tl != NULL);

Reach line at /src/cyclonedds/src/core/ddsi/src/ddsi_serdata_pserop.c:147 (observed count 0).


  290 |   return true;
  291 | }
  292 |
  293 | void *ddsi_entidx_lookup_guid_untyped (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  294 | {
  295 |   /* FIXME: could (now) require guid to be first in entity_common; entity_common already is first in entity */
  296 |   struct ddsi_entity_common e;
  297 |   e.guid = *guid;
  298 |   assert (ddsi_thread_is_awake ());
  299 |   return ddsrt_chh_lookup (ei->guid_hash, &e);
  300 | }
  301 |
  302 | static void *entidx_lookup_guid_int (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid, enum ddsi_entity_kind kind)
  303 | {
  304 |   struct ddsi_entity_common *res;
  305 |   if ((res = ddsi_entidx_lookup_guid_untyped (ei, guid)) != NULL && res->kind == kind)
  306 |     return res;
  307 |   else
  308 |     return NULL;
  309 | }
  310 |
  311 | void *ddsi_entidx_lookup_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid, enum ddsi_entity_kind kind)
  312 | {
  313 |   return entidx_lookup_guid_int (ei, guid, kind);
  314 | }
  315 |
  316 | void ddsi_entidx_insert_participant_guid (struct ddsi_entity_index *ei, struct ddsi_participant *pp)
  317 | {
  318 |   entity_index_insert (ei, &pp->e);
  319 | }
  320 |
  321 | void ddsi_entidx_insert_proxy_participant_guid (struct ddsi_entity_index *ei, struct ddsi_proxy_participant *proxypp)
  322 | {
  323 |   entity_index_insert (ei, &proxypp->e);
  324 | }
  325 |
  326 | void ddsi_entidx_insert_writer_guid (struct ddsi_entity_index *ei, struct ddsi_writer *wr)
  327 | {
  328 |   entity_index_insert (ei, &wr->e);
  329 | }
  330 |
  331 | void ddsi_entidx_insert_reader_guid (struct ddsi_entity_index *ei, struct ddsi_reader *rd)
  332 | {
  333 |   entity_index_insert (ei, &rd->e);
  334 | }
  335 |
  336 | void ddsi_entidx_insert_proxy_writer_guid (struct ddsi_entity_index *ei, struct ddsi_proxy_writer *pwr)
  337 | {
  338 |   entity_index_insert (ei, &pwr->e);
  339 | }
  340 |
  341 | void ddsi_entidx_insert_proxy_reader_guid (struct ddsi_entity_index *ei, struct ddsi_proxy_reader *prd)
  342 | {
  343 |   entity_index_insert (ei, &prd->e);
  344 | }
  345 |
  346 | struct ddsi_participant *ddsi_entidx_tryremove_participant_guid (struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  347 | {
  348 |   struct ddsi_participant *pp = ddsi_entidx_lookup_participant_guid (ei, guid);
  349 |   if (pp == NULL || !entity_index_tryremove (ei, &pp->e))
  350 |     return NULL;
  351 |   return pp;
  352 | }
  353 |
  354 | struct ddsi_proxy_participant *ddsi_entidx_tryremove_proxy_participant_guid (struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  355 | {
  356 |   struct ddsi_proxy_participant *proxypp = ddsi_entidx_lookup_proxy_participant_guid (ei, guid);
  357 |   if (proxypp == NULL || !entity_index_tryremove (ei, &proxypp->e))
  358 |     return NULL;
  359 |   return proxypp;
  360 | }
  361 |
  362 | struct ddsi_writer *ddsi_entidx_tryremove_writer_guid (struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  363 | {
  364 |   struct ddsi_writer *wr = ddsi_entidx_lookup_writer_guid (ei, guid);
  365 |   if (wr == NULL || !entity_index_tryremove (ei, &wr->e))
  366 |     return NULL;
  367 |   return wr;
  368 | }
  369 |
  370 | struct ddsi_reader *ddsi_entidx_tryremove_reader_guid (struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  371 | {
  372 |   struct ddsi_reader *rd = ddsi_entidx_lookup_reader_guid (ei, guid);
  373 |   if (rd == NULL || !entity_index_tryremove (ei, &rd->e))
  374 |     return NULL;
  375 |   return rd;
  376 | }
  377 |
  378 | struct ddsi_proxy_writer *ddsi_entidx_tryremove_proxy_writer_guid (struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  379 | {
  380 |   struct ddsi_proxy_writer *pwr = ddsi_entidx_lookup_proxy_writer_guid (ei, guid);
  381 |   if (pwr == NULL || !entity_index_tryremove (ei, &pwr->e))
  382 |     return NULL;
  383 |   return pwr;
  384 | }
  385 |
  386 | struct ddsi_proxy_reader *ddsi_entidx_tryremove_proxy_reader_guid (struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  387 | {
  388 |   struct ddsi_proxy_reader *prd = ddsi_entidx_lookup_proxy_reader_guid (ei, guid);
  389 |   if (prd == NULL || !entity_index_tryremove (ei, &prd->e))
> 390 |     return NULL;
  391 |   return prd;
  392 | }
  393 |
  394 | struct ddsi_participant *ddsi_entidx_lookup_participant_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  395 | {
  396 |   DDSRT_STATIC_ASSERT (offsetof (struct ddsi_participant, e) == 0);
  397 |   assert (guid->entityid.u == DDSI_ENTITYID_PARTICIPANT);
  398 |   return entidx_lookup_guid_int (ei, guid, DDSI_EK_PARTICIPANT);
  399 | }
  400 |
  401 | struct ddsi_proxy_participant *ddsi_entidx_lookup_proxy_participant_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  402 | {
  403 |   DDSRT_STATIC_ASSERT (offsetof (struct ddsi_proxy_participant, e) == 0);
  404 |   assert (guid->entityid.u == DDSI_ENTITYID_PARTICIPANT);
  405 |   return entidx_lookup_guid_int (ei, guid, DDSI_EK_PROXY_PARTICIPANT);
  406 | }
  407 |
  408 | struct ddsi_writer *ddsi_entidx_lookup_writer_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  409 | {
  410 |   DDSRT_STATIC_ASSERT (offsetof (struct ddsi_writer, e) == 0);
  411 |   assert (ddsi_is_writer_entityid (guid->entityid));
  412 |   return entidx_lookup_guid_int (ei, guid, DDSI_EK_WRITER);
  413 | }
  414 |
  415 | struct ddsi_reader *ddsi_entidx_lookup_reader_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  416 | {
  417 |   DDSRT_STATIC_ASSERT (offsetof (struct ddsi_reader, e) == 0);
  418 |   assert (ddsi_is_reader_entityid (guid->entityid));
  419 |   return entidx_lookup_guid_int (ei, guid, DDSI_EK_READER);
  420 | }
  421 |
  422 | struct ddsi_proxy_writer *ddsi_entidx_lookup_proxy_writer_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  423 | {
  424 |   DDSRT_STATIC_ASSERT (offsetof (struct ddsi_proxy_writer, e) == 0);
  425 |   assert (ddsi_is_writer_entityid (guid->entityid));
  426 |   return entidx_lookup_guid_int (ei, guid, DDSI_EK_PROXY_WRITER);
  427 | }
  428 |
  429 | struct ddsi_proxy_reader *ddsi_entidx_lookup_proxy_reader_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid)
  430 | {
  431 |   DDSRT_STATIC_ASSERT (offsetof (struct ddsi_proxy_reader, e) == 0);
  432 |   assert (ddsi_is_reader_entityid (guid->entityid));
  433 |   return entidx_lookup_guid_int (ei, guid, DDSI_EK_PROXY_READER);
  434 | }
  435 |
  436 | /* Enumeration */
  437 |
  438 | static void entidx_enum_init_minmax_int (struct ddsi_entity_enum *st, const struct ddsi_entity_index *ei, const struct ddsi_match_entities_range_key *min)
  439 | {
  440 |   /* Use a lock to protect against concurrent modification and rely on the GC not deleting
  441 |      any entities while enumerating so we can rely on the (kind, topic, GUID) triple to
  442 |      remain valid for looking up the next entity.  With a bit of additional effort it would
  443 |      be possible to allow the GC to reclaim any entities already visited, but I don't think
  444 |      that additional effort is worth it. */
  445 | #ifndef NDEBUG
  446 |   assert (ddsi_thread_is_awake ());
  447 |   st->vtime = ddsrt_atomic_ld32 (&ddsi_lookup_thread_state ()->vtime);
  448 | #endif
  449 |   st->entidx = (struct ddsi_entity_index *) ei;
  450 |   st->kind = min->entity.e.kind;
  451 |   ddsrt_mutex_lock (&st->entidx->all_entities_lock);
  452 |   st->cur = ddsrt_avl_lookup_succ_eq (&all_entities_treedef, &st->entidx->all_entities, min);
  453 |   ddsrt_mutex_unlock (&st->entidx->all_entities_lock);
  454 | }
  455 |
  456 | void ddsi_entidx_enum_init_topic (struct ddsi_entity_enum *st, const struct ddsi_entity_index *ei, enum ddsi_entity_kind kind, const char *topic, struct ddsi_match_entities_range_key *max)
  457 | {
  458 |   assert (kind == DDSI_EK_READER || kind == DDSI_EK_WRITER || kind == DDSI_EK_PROXY_READER || kind == DDSI_EK_PROXY_WRITER);
  459 |   struct ddsi_match_entities_range_key min;
  460 |   match_endpoint_range (kind, topic, &min, max);
  461 |   entidx_enum_init_minmax_int (st, ei, &min);
  462 |   if (st->cur && all_entities_compare (st->cur, &max->entity) > 0)
  463 |     st->cur = NULL;
  464 | }
  465 |
  466 | void ddsi_entidx_enum_init_topic_w_prefix (struct ddsi_entity_enum *st, const struct ddsi_entity_index *ei, enum ddsi_entity_kind kind, const char *topic, const ddsi_guid_prefix_t *prefix, struct ddsi_match_entities_range_key *max)
  467 | {
  468 |   assert (kind == DDSI_EK_READER || kind == DDSI_EK_WRITER || kind == DDSI_EK_PROXY_READER || kind == DDSI_EK_PROXY_WRITER);
  469 |   struct ddsi_match_entities_range_key min;
  470 |   match_endpoint_range (kind, topic, &min, max);
  471 |   min.entity.e.guid.prefix = *prefix;
  472 |   max->entity.e.guid.prefix = *prefix;
  473 |   entidx_enum_init_minmax_int (st, ei, &min);
  474 |   if (st->cur && all_entities_compare (st->cur, &max->entity) > 0)
  475 |     st->cur = NULL;
  476 | }
  477 |
  478 | void ddsi_entidx_enum_init (struct ddsi_entity_enum *st, const struct ddsi_entity_index *ei, enum ddsi_entity_kind kind)
  479 | {
  480 |   struct ddsi_match_entities_range_key min;
  481 |   match_entity_kind_min (kind, &min);
  482 |   entidx_enum_init_minmax_int (st, ei, &min);
  483 |   if (st->cur && st->cur->kind != st->kind)
  484 |     st->cur = NULL;
  485 | }
  486 |
  487 | void ddsi_entidx_enum_writer_init (struct ddsi_entity_enum_writer *st, const struct ddsi_entity_index *ei)
  488 | {
  489 |   ddsi_entidx_enum_init (&st->st, ei, DDSI_EK_WRITER);
  490 | }

Reach line at /src/cyclonedds/src/core/ddsi/src/ddsi_entity_index.c:390 (observed count 0).


  480 |     FUNC_ENTER_NOAPI(FAIL)
  481 |
  482 |     /* Sanity check */
  483 |     assert(f);
  484 |     assert(f->obj_count);
  485 |     assert(H5_addr_defined(addr));
  486 |
  487 |     /* Get the object node from the container */
  488 |     if (NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) {
  489 |         /* Decrement the reference count for the object */
  490 |         (obj_count->count)--;
  491 |
  492 |         if (obj_count->count == 0) {
  493 |             /* Remove from container */
  494 |             if (NULL == (obj_count = (H5FO_obj_count_t *)H5SL_remove(f->obj_count, &addr)))
  495 |                 HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "can't remove object from container");
  496 |
  497 |             /* Release the object information */
  498 |             obj_count = H5FL_FREE(H5FO_obj_count_t, obj_count);
  499 |         } /* end if */
  500 |     }     /* end if */
  501 |     else
  502 |         HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't decrement ref. count");
  503 |
  504 | done:
  505 |     FUNC_LEAVE_NOAPI(ret_value)
  506 | } /* end H5FO_top_decr() */
  507 |
  508 | /*--------------------------------------------------------------------------
  509 |  NAME
  510 |     H5FO_top_count
  511 |  PURPOSE
  512 |     Return the "top" reference count for an object in a file
  513 |  USAGE
  514 |     hsize_t H5FO_top_count(f, addr)
  515 |         H5F_t *f;               IN/OUT: File's opened object info set
  516 |         haddr_t addr;           IN: Address of object to increment
  517 |
  518 |  RETURNS
  519 |     Returns a non-negative on success, negative on failure
  520 |  DESCRIPTION
  521 |     Retrieves the reference count for an object in the opened object count set.
  522 |  GLOBAL VARIABLES
  523 |  COMMENTS, BUGS, ASSUMPTIONS
  524 |  EXAMPLES
  525 |  REVISION LOG
  526 | --------------------------------------------------------------------------*/
  527 | hsize_t
  528 | H5FO_top_count(const H5F_t *f, haddr_t addr)
  529 | {
  530 |     H5FO_obj_count_t *obj_count; /* Ref. count for object */
  531 |     hsize_t           ret_value; /* Return value */
  532 |
  533 |     FUNC_ENTER_NOAPI_NOINIT_NOERR
  534 |
  535 |     /* Sanity check */
  536 |     assert(f);
  537 |     assert(f->obj_count);
  538 |     assert(H5_addr_defined(addr));
  539 |
  540 |     /* Get the object node from the container */
  541 |     if (NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr)))
  542 |         ret_value = obj_count->count;
  543 |     else
  544 |         ret_value = 0;
  545 |
  546 |     FUNC_LEAVE_NOAPI(ret_value)
  547 | } /* end H5FO_top_count() */
  548 |
  549 | /*--------------------------------------------------------------------------
  550 |  NAME
  551 |     H5FO_top_dest
  552 |  PURPOSE
  553 |     Destroy an open object info set
  554 |  USAGE
  555 |     herr_t H5FO_top_dest(f)
  556 |         H5F_t *f;               IN/OUT: File's opened object info set
  557 |
  558 |  RETURNS
  559 |     Returns a non-negative on success, negative on failure
  560 |  DESCRIPTION
  561 |     Destroy an existing open object info set.
  562 |  GLOBAL VARIABLES
  563 |  COMMENTS, BUGS, ASSUMPTIONS
  564 |  EXAMPLES
  565 |  REVISION LOG
  566 | --------------------------------------------------------------------------*/
  567 | herr_t
  568 | H5FO_top_dest(H5F_t *f)
  569 | {
  570 |     herr_t ret_value = SUCCEED; /* Return value */
  571 |
  572 |     FUNC_ENTER_NOAPI(FAIL)
  573 |
  574 |     /* Sanity check */
  575 |     assert(f);
  576 |     assert(f->obj_count);
  577 |
  578 |     /* Check if the object count set is empty */
  579 |     if (H5SL_count(f->obj_count) != 0)
> 580 |         HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "objects still in open object info set");
  581 |
  582 |     /* Release the open object count set container */
  583 |     if (H5SL_close(f->obj_count) < 0)
  584 |         HGOTO_ERROR(H5E_CACHE, H5E_CANTCLOSEOBJ, FAIL, "can't close open object info set");
  585 |
  586 |     f->obj_count = NULL;
  587 |
  588 | done:
  589 |     FUNC_LEAVE_NOAPI(ret_value)
  590 | } /* end H5FO_top_dest() */

Reach line at /src/hdf5/src/H5FO.c:580 (observed count 0).


  591 |     assert(H5_addr_defined(addr));
  592 |
  593 |     if (H5C_expunge_entry(f, type, addr, flags) < 0)
  594 |         HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "H5C_expunge_entry() failed");
  595 |
  596 | done:
  597 |     /* If currently logging, generate a message */
  598 |     if (f->shared->cache->log_info->logging)
  599 |         if (H5C_log_write_expunge_entry_msg(f->shared->cache, addr, type->id, ret_value) < 0)
  600 |             HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
  601 |
  602 |     FUNC_LEAVE_NOAPI(ret_value)
  603 | } /* H5AC_expunge_entry() */
  604 |
  605 | /*-------------------------------------------------------------------------
  606 |  * Function:    H5AC_flush
  607 |  *
  608 |  * Purpose:     Flush (and possibly destroy) the metadata cache associated
  609 |  *              with the specified file.
  610 |  *
  611 |  *              If the cache contains protected entries, the function will
  612 |  *              fail, as protected entries cannot be flushed.  However
  613 |  *              all unprotected entries should be flushed before the
  614 |  *              function returns failure.
  615 |  *
  616 |  * Return:      Non-negative on success/Negative on failure if there was a
  617 |  *              request to flush all items and something was protected.
  618 |  *
  619 |  *-------------------------------------------------------------------------
  620 |  */
  621 | herr_t
  622 | H5AC_flush(H5F_t *f)
  623 | {
  624 |     herr_t ret_value = SUCCEED; /* Return value */
  625 |
  626 |     FUNC_ENTER_NOAPI(FAIL)
  627 |
  628 |     /* Sanity checks */
  629 |     assert(f);
  630 |     assert(f->shared);
  631 |     assert(f->shared->cache);
  632 |
  633 | #ifdef H5_HAVE_PARALLEL
  634 |     /* flushing the cache, so clear all collective entries */
  635 |     if (H5C_clear_coll_entries(f->shared->cache, false) < 0)
  636 |         HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed");
  637 |
  638 |     /* Attempt to flush all entries from rank 0 & Bcast clean list to other ranks */
  639 |     if (H5AC__flush_entries(f) < 0)
  640 |         HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush");
  641 | #endif /* H5_HAVE_PARALLEL */
  642 |
  643 |     /* Flush the cache */
  644 |     /* (Again, in parallel - writes out the superblock) */
  645 |     if (H5C_flush_cache(f, H5AC__NO_FLAGS_SET) < 0)
  646 |         HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush cache");
  647 |
  648 | done:
  649 |     /* If currently logging, generate a message */
  650 |     if (f->shared->cache->log_info->logging)
  651 |         if (H5C_log_write_flush_cache_msg(f->shared->cache, ret_value) < 0)
  652 |             HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
  653 |
  654 |     FUNC_LEAVE_NOAPI(ret_value)
  655 | } /* H5AC_flush() */
  656 |
  657 | /*-------------------------------------------------------------------------
  658 |  * Function:    H5AC_get_entry_status
  659 |  *
  660 |  * Purpose:     Given a file address, determine whether the metadata
  661 |  *              cache contains an entry at that location.  If it does,
  662 |  *              also determine whether the entry is dirty, protected,
  663 |  *              pinned, etc. and return that information to the caller
  664 |  *              in *status.
  665 |  *
  666 |  *              If the specified entry doesn't exist, set *status_ptr
  667 |  *              to zero.
  668 |  *
  669 |  *              On error, the value of *status is undefined.
  670 |  *
  671 |  * Return:      Non-negative on success/Negative on failure
  672 |  *
  673 |  *-------------------------------------------------------------------------
  674 |  */
  675 | herr_t
  676 | H5AC_get_entry_status(const H5F_t *f, haddr_t addr, unsigned *status)
  677 | {
  678 |     bool   in_cache;     /* Entry @ addr is in the cache */
  679 |     bool   is_dirty;     /* Entry @ addr is in the cache and dirty */
  680 |     bool   is_protected; /* Entry @ addr is in the cache and protected */
  681 |     bool   is_pinned;    /* Entry @ addr is in the cache and pinned */
  682 |     bool   is_corked;
  683 |     bool   is_flush_dep_child;  /* Entry @ addr is in the cache and is a flush dependency child */
  684 |     bool   is_flush_dep_parent; /* Entry @ addr is in the cache and is a flush dependency parent */
  685 |     bool   image_is_up_to_date; /* Entry @ addr is in the cache and has an up to date image */
  686 |     herr_t ret_value = SUCCEED; /* Return value */
  687 |
  688 |     FUNC_ENTER_NOAPI(FAIL)
  689 |
  690 |     if ((f == NULL) || (!H5_addr_defined(addr)) || (status == NULL))
> 691 |         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad param(s) on entry");
  692 |
  693 |     if (H5C_get_entry_status(f, addr, NULL, &in_cache, &is_dirty, &is_protected, &is_pinned, &is_corked,
  694 |                              &is_flush_dep_parent, &is_flush_dep_child, &image_is_up_to_date) < 0)
  695 |         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_entry_status() failed");
  696 |
  697 |     if (in_cache) {
  698 |         *status |= H5AC_ES__IN_CACHE;
  699 |         if (is_dirty)
  700 |             *status |= H5AC_ES__IS_DIRTY;
  701 |         if (is_protected)
  702 |             *status |= H5AC_ES__IS_PROTECTED;
  703 |         if (is_pinned)
  704 |             *status |= H5AC_ES__IS_PINNED;
  705 |         if (is_corked)
  706 |             *status |= H5AC_ES__IS_CORKED;
  707 |         if (is_flush_dep_parent)
  708 |             *status |= H5AC_ES__IS_FLUSH_DEP_PARENT;
  709 |         if (is_flush_dep_child)
  710 |             *status |= H5AC_ES__IS_FLUSH_DEP_CHILD;
  711 |         if (image_is_up_to_date)
  712 |             *status |= H5AC_ES__IMAGE_IS_UP_TO_DATE;
  713 |     } /* end if */
  714 |     else
  715 |         *status = 0;
  716 |
  717 | done:
  718 |     FUNC_LEAVE_NOAPI(ret_value)
  719 | } /* H5AC_get_entry_status() */
  720 |
  721 | /*-------------------------------------------------------------------------
  722 |  * Function:    H5AC_insert_entry
  723 |  *
  724 |  * Purpose:     Adds the specified thing to the cache.  The thing need not
  725 |  *              exist on disk yet, but it must have an address and disk
  726 |  *              space reserved.
  727 |  *
  728 |  * Return:      Non-negative on success/Negative on failure
  729 |  *
  730 |  *-------------------------------------------------------------------------
  731 |  */
  732 | herr_t
  733 | H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned int flags)
  734 | {
  735 |     herr_t ret_value = SUCCEED; /* Return value */
  736 |
  737 |     FUNC_ENTER_NOAPI(FAIL)
  738 |
  739 |     /* Sanity checks */
  740 |     assert(f);
  741 |     assert(f->shared);
  742 |     assert(f->shared->cache);
  743 |     assert(type);
  744 |     assert(type->serialize);
  745 |     assert(H5_addr_defined(addr));
  746 |     assert(thing);
  747 |
  748 |     /* Check for invalid access request */
  749 |     if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR))
  750 |         HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file");
  751 |
  752 | #if H5AC_DO_TAGGING_SANITY_CHECKS
  753 |     if (!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0)
  754 |         HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Bad tag value");
  755 | #endif /* H5AC_DO_TAGGING_SANITY_CHECKS */
  756 |
  757 |     /* Insert entry into metadata cache */
  758 |     if (H5C_insert_entry(f, type, addr, thing, flags) < 0)
  759 |         HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C_insert_entry() failed");
  760 |
  761 | #ifdef H5_HAVE_PARALLEL
  762 |     {
  763 |         H5AC_aux_t *aux_ptr;
  764 |
  765 |         if (NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) {
  766 |             /* Log the new entry */
  767 |             if (H5AC__log_inserted_entry((H5AC_info_t *)thing) < 0)
  768 |                 HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5AC__log_inserted_entry() failed");
  769 |
  770 |             /* Check if we should try to flush */
  771 |             if (aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold)
  772 |                 if (H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0)
  773 |                     HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point");
  774 |         } /* end if */
  775 |     }
  776 | #endif /* H5_HAVE_PARALLEL */
  777 |
  778 | done:
  779 |     /* If currently logging, generate a message */
  780 |     if (f->shared->cache->log_info->logging)
  781 |         if (H5C_log_write_insert_entry_msg(f->shared->cache, addr, type->id, flags,
  782 |                                            ((H5C_cache_entry_t *)thing)->size, ret_value) < 0)
  783 |             HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
  784 |
  785 |     FUNC_LEAVE_NOAPI(ret_value)
  786 | } /* H5AC_insert_entry() */
  787 |
  788 | /*-------------------------------------------------------------------------
  789 |  * Function:    H5AC_load_cache_image_on_next_protect
  790 |  *
  791 |  * Purpose:     Load the cache image block at the specified location,

Reach line at /src/hdf5/src/H5AC.c:691 (observed count 0).


   57 |     H5F_ACCUM_APPEND   /* Data will be appended to accumulator */
   58 | } H5F_accum_adjust_t;
   59 |
   60 | /********************/
   61 | /* Package Typedefs */
   62 | /********************/
   63 |
   64 | /********************/
   65 | /* Local Prototypes */
   66 | /********************/
   67 |
   68 | /*********************/
   69 | /* Package Variables */
   70 | /*********************/
   71 |
   72 | /*****************************/
   73 | /* Library Private Variables */
   74 | /*****************************/
   75 |
   76 | /*******************/
   77 | /* Local Variables */
   78 | /*******************/
   79 |
   80 | /* Declare a PQ free list to manage the metadata accumulator buffer */
   81 | H5FL_BLK_DEFINE_STATIC(meta_accum);
   82 |
   83 | /*-------------------------------------------------------------------------
   84 |  * Function:	H5F__accum_read
   85 |  *
   86 |  * Purpose:	Attempts to read some data from the metadata accumulator for
   87 |  *              a file into a buffer.
   88 |  *
   89 |  * Note:	We can't change (or add to) the metadata accumulator, because
   90 |  *		this might be a speculative read and could possibly read raw
   91 |  *		data into the metadata accumulator.
   92 |  *
   93 |  * Return:	Non-negative on success/Negative on failure
   94 |  *
   95 |  *-------------------------------------------------------------------------
   96 |  */
   97 | herr_t
   98 | H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, size_t size, void *buf /*out*/)
   99 | {
  100 |     H5FD_t *file;                /* File driver pointer */
  101 |     herr_t  ret_value = SUCCEED; /* Return value */
  102 |
  103 |     FUNC_ENTER_PACKAGE
  104 |
  105 |     /* Sanity checks */
  106 |     assert(f_sh);
  107 |     assert(buf);
  108 |
  109 |     /* Translate to file driver I/O info object */
  110 |     file = f_sh->lf;
  111 |
  112 |     /* Check if this information is in the metadata accumulator */
  113 |     if ((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) {
  114 |         H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */
  115 |
  116 |         /* Set up alias for file's metadata accumulator info */
  117 |         accum = &f_sh->accum;
  118 |
  119 |         if (size < H5F_ACCUM_MAX_SIZE) {
  120 |             /* Sanity check */
  121 |             assert(!accum->buf || (accum->alloc_size >= accum->size));
  122 |
  123 |             /* Current read adjoins or overlaps with metadata accumulator */
  124 |             if (H5_addr_defined(accum->loc) &&
  125 |                 (H5_addr_overlap(addr, size, accum->loc, accum->size) || ((addr + size) == accum->loc) ||
  126 |                  (accum->loc + accum->size) == addr)) {
  127 |                 size_t  amount_before; /* Amount to read before current accumulator */
  128 |                 haddr_t new_addr;      /* New address of the accumulator buffer */
  129 |                 size_t  new_size;      /* New size of the accumulator buffer */
  130 |
  131 |                 /* Compute new values for accumulator */
  132 |                 new_addr = MIN(addr, accum->loc);
  133 |                 new_size = (size_t)(MAX((addr + size), (accum->loc + accum->size)) - new_addr);
  134 |
  135 |                 /* Check if we need more buffer space */
  136 |                 if (new_size > accum->alloc_size) {
  137 |                     size_t new_alloc_size; /* New size of accumulator */
  138 |
  139 |                     /* Adjust the buffer size to be a power of 2 that is large enough to hold data */
  140 |                     new_alloc_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(new_size - 1)));
  141 |
  142 |                     /* Reallocate the metadata accumulator buffer */
  143 |                     if (NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_alloc_size)))
  144 |                         HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
  145 |                                     "unable to allocate metadata accumulator buffer");
  146 |
  147 |                     /* Note the new buffer size */
  148 |                     accum->alloc_size = new_alloc_size;
  149 |
  150 |                     /* Clear the memory */
  151 |                     memset(accum->buf + accum->size, 0, (accum->alloc_size - accum->size));
  152 |                 } /* end if */
  153 |
  154 |                 /* Read the part before the metadata accumulator */
  155 |                 if (addr < accum->loc) {
  156 |                     /* Set the amount to read */
> 157 |                     H5_CHECKED_ASSIGN(amount_before, size_t, (accum->loc - addr), hsize_t);
  158 |
  159 |                     /* Make room for the metadata to read in */
  160 |                     memmove(accum->buf + amount_before, accum->buf, accum->size);
  161 |
  162 |                     /* Adjust dirty region tracking info, if present */
  163 |                     if (accum->dirty)
  164 |                         accum->dirty_off += amount_before;
  165 |
  166 |                     /* Dispatch to driver */
  167 |                     if (H5FD_read(file, map_type, addr, amount_before, accum->buf) < 0)
  168 |                         HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed");
  169 |                 } /* end if */
  170 |                 else
  171 |                     amount_before = 0;
  172 |
  173 |                 /* Read the part after the metadata accumulator */
  174 |                 if ((addr + size) > (accum->loc + accum->size)) {
  175 |                     size_t amount_after; /* Amount to read at a time */
  176 |
  177 |                     /* Set the amount to read */
  178 |                     H5_CHECKED_ASSIGN(amount_after, size_t, ((addr + size) - (accum->loc + accum->size)),
  179 |                                       hsize_t);
  180 |
  181 |                     /* Dispatch to driver */
  182 |                     if (H5FD_read(file, map_type, (accum->loc + accum->size), amount_after,
  183 |                                   (accum->buf + accum->size + amount_before)) < 0)
  184 |                         HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed");
  185 |                 } /* end if */
  186 |
  187 |                 /* Copy the data out of the buffer */
  188 |                 H5MM_memcpy(buf, accum->buf + (addr - new_addr), size);
  189 |
  190 |                 /* Adjust the accumulator address & size */
  191 |                 accum->loc  = new_addr;
  192 |                 accum->size = new_size;
  193 |             } /* end if */
  194 |             /* Current read doesn't overlap with metadata accumulator, read it from file */
  195 |             else {
  196 |                 /* Dispatch to driver */
  197 |                 if (H5FD_read(file, map_type, addr, size, buf) < 0)
  198 |                     HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed");
  199 |             } /* end else */
  200 |         }     /* end if */
  201 |         else {
  202 |             /* Read the data */
  203 |             if (H5FD_read(file, map_type, addr, size, buf) < 0)
  204 |                 HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed");
  205 |
  206 |             /* Check for overlap w/dirty accumulator */
  207 |             /* (Note that this could be improved by updating the non-dirty
  208 |              *  information in the accumulator with [some of] the information
  209 |              *  just read in. -QAK)
  210 |              */
  211 |             if (accum->dirty &&
  212 |                 H5_addr_overlap(addr, size, accum->loc + accum->dirty_off, accum->dirty_len)) {
  213 |                 haddr_t dirty_loc = accum->loc + accum->dirty_off; /* File offset of dirty information */
  214 |                 size_t  buf_off;                                   /* Offset of dirty region in buffer */
  215 |                 size_t  dirty_off;                                 /* Offset within dirty region */
  216 |                 size_t  overlap_size;                              /* Size of overlap with dirty region */
  217 |
  218 |                 /* Check for read starting before beginning dirty region */
  219 |                 if (H5_addr_le(addr, dirty_loc)) {
  220 |                     /* Compute offset of dirty region within buffer */
  221 |                     buf_off = (size_t)(dirty_loc - addr);
  222 |
  223 |                     /* Compute offset within dirty region */
  224 |                     dirty_off = 0;
  225 |
  226 |                     /* Check for read ending within dirty region */
  227 |                     if (H5_addr_lt(addr + size, dirty_loc + accum->dirty_len))
  228 |                         overlap_size = (size_t)((addr + size) - buf_off);
  229 |                     else /* Access covers whole dirty region */
  230 |                         overlap_size = accum->dirty_len;
  231 |                 }      /* end if */
  232 |                 else { /* Read starts after beginning of dirty region */
  233 |                     /* Compute dirty offset within buffer and overlap size */
  234 |                     buf_off      = 0;
  235 |                     dirty_off    = (size_t)(addr - dirty_loc);
  236 |                     overlap_size = (size_t)((dirty_loc + accum->dirty_len) - addr);
  237 |                 } /* end else */
  238 |
  239 |                 /* Copy the dirty region to buffer */
  240 |                 H5MM_memcpy((unsigned char *)buf + buf_off,
  241 |                             (unsigned char *)accum->buf + accum->dirty_off + dirty_off, overlap_size);
  242 |             } /* end if */
  243 |         }     /* end else */
  244 |     }         /* end if */
  245 |     else {
  246 |         /* Read the data */
  247 |         if (H5FD_read(file, map_type, addr, size, buf) < 0)
  248 |             HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed");
  249 |     } /* end else */
  250 |
  251 | done:
  252 |     FUNC_LEAVE_NOAPI(ret_value)
  253 | } /* end H5F__accum_read() */
  254 |
  255 | /*-------------------------------------------------------------------------
  256 |  * Function:	H5F__accum_adjust
  257 |  *

Reach line at /src/hdf5/src/H5Faccum.c:157 (observed count 0).