Subversion Repositories Kolibri OS

Rev

Rev 6082 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6082 Rev 6293
Line 39... Line 39...
39
#define dereference_function_descriptor(p) (p)
39
#define dereference_function_descriptor(p) (p)
40
#endif
40
#endif
Line 41... Line 41...
41
 
41
 
Line 42... Line -...
42
#define KSTRTOX_OVERFLOW        (1U << 31)
-
 
43
 
-
 
-
 
42
#define KSTRTOX_OVERFLOW        (1U << 31)
Line 44... Line 43...
44
const char hex_asc[] = "0123456789abcdef";
43
 
45
const char hex_asc_upper[] = "0123456789ABCDEF";
44
 
Line 1078... Line 1077...
1078
 *       (legacy clock framework) of the clock
1077
 *       (legacy clock framework) of the clock
1079
 * - 'Cn' For a clock, it prints the name (Common Clock Framework) or address
1078
 * - 'Cn' For a clock, it prints the name (Common Clock Framework) or address
1080
 *        (legacy clock framework) of the clock
1079
 *        (legacy clock framework) of the clock
1081
 * - 'Cr' For a clock, it prints the current rate of the clock
1080
 * - 'Cr' For a clock, it prints the current rate of the clock
1082
 *
1081
 *
-
 
1082
 * ** Please update also Documentation/printk-formats.txt when making changes **
-
 
1083
 *
1083
 * Note: The difference between 'S' and 'F' is that on ia64 and ppc64
1084
 * Note: The difference between 'S' and 'F' is that on ia64 and ppc64
1084
 * function pointers are really function descriptors, which contain a
1085
 * function pointers are really function descriptors, which contain a
1085
 * pointer to the real address.
1086
 * pointer to the real address.
1086
 */
1087
 */
1087
static noinline_for_stack
1088
static noinline_for_stack
1088
char *pointer(const char *fmt, char *buf, char *end, void *ptr,
1089
char *pointer(const char *fmt, char *buf, char *end, void *ptr,
1089
	      struct printf_spec spec)
1090
	      struct printf_spec spec)
1090
{
1091
{
1091
	int default_width = 2 * sizeof(void *) + (spec.flags & SPECIAL ? 2 : 0);
1092
	const int default_width = 2 * sizeof(void *);
Line 1092... Line 1093...
1092
 
1093
 
1093
	if (!ptr && *fmt != 'K') {
1094
	if (!ptr && *fmt != 'K') {
1094
		/*
1095
		/*
1095
		 * Print (null) with the same width as a pointer so it makes
1096
		 * Print (null) with the same width as a pointer so it makes
Line 1313... Line 1314...
1313
	case 'u':
1314
	case 'u':
1314
		break;
1315
		break;
Line 1315... Line 1316...
1315
 
1316
 
1316
	case 'n':
1317
	case 'n':
1317
		/*
1318
		/*
1318
		 * Since %n poses a greater security risk than utility, treat
1319
		 * Since %n poses a greater security risk than
1319
		 * it as an invalid format specifier. Warn about its use so
1320
		 * utility, treat it as any other invalid or
1320
		 * that new instances don't get added.
1321
		 * unsupported format specifier.
1321
		 */
-
 
1322
//       WARN_ONCE(1, "Please remove ignored %%n in '%s'\n", fmt);
1322
		 */
Line 1323... Line 1323...
1323
		/* Fall-through */
1323
		/* Fall-through */
1324
 
1324
 
1325
	default:
1325
	default:
Line 1355... Line 1355...
1355
 * @buf: The buffer to place the result into
1355
 * @buf: The buffer to place the result into
1356
 * @size: The size of the buffer, including the trailing null space
1356
 * @size: The size of the buffer, including the trailing null space
1357
 * @fmt: The format string to use
1357
 * @fmt: The format string to use
1358
 * @args: Arguments for the format string
1358
 * @args: Arguments for the format string
1359
 *
1359
 *
1360
 * This function follows C99 vsnprintf, but has some extensions:
1360
 * This function generally follows C99 vsnprintf, but has some
1361
 * %pS output the name of a text symbol with offset
-
 
1362
 * %ps output the name of a text symbol without offset
-
 
1363
 * %pF output the name of a function pointer with its offset
-
 
1364
 * %pf output the name of a function pointer without its offset
-
 
1365
 * %pB output the name of a backtrace symbol with its offset
-
 
1366
 * %pR output the address range in a struct resource with decoded flags
-
 
1367
 * %pr output the address range in a struct resource with raw flags
-
 
1368
 * %pb output the bitmap with field width as the number of bits
-
 
1369
 * %pbl output the bitmap as range list with field width as the number of bits
-
 
1370
 * %pM output a 6-byte MAC address with colons
-
 
1371
 * %pMR output a 6-byte MAC address with colons in reversed order
-
 
1372
 * %pMF output a 6-byte MAC address with dashes
-
 
1373
 * %pm output a 6-byte MAC address without colons
-
 
1374
 * %pmR output a 6-byte MAC address without colons in reversed order
-
 
1375
 * %pI4 print an IPv4 address without leading zeros
-
 
1376
 * %pi4 print an IPv4 address with leading zeros
-
 
1377
 * %pI6 print an IPv6 address with colons
1361
 * extensions and a few limitations:
1378
 * %pi6 print an IPv6 address without colons
-
 
1379
 * %pI6c print an IPv6 address as specified by RFC 5952
-
 
1380
 * %pIS depending on sa_family of 'struct sockaddr *' print IPv4/IPv6 address
-
 
1381
 * %piS depending on sa_family of 'struct sockaddr *' print IPv4/IPv6 address
-
 
1382
 * %pU[bBlL] print a UUID/GUID in big or little endian using lower or upper
-
 
1383
 *   case.
1362
 *
1384
 * %*pE[achnops] print an escaped buffer
1363
 * %n is unsupported
1385
 * %*ph[CDN] a variable-length hex string with a separator (supports up to 64
-
 
1386
 *           bytes of the input)
1364
 * %p* is handled by pointer()
1387
 * %pC output the name (Common Clock Framework) or address (legacy clock
-
 
1388
 *     framework) of a clock
-
 
1389
 * %pCn output the name (Common Clock Framework) or address (legacy clock
-
 
1390
 *      framework) of a clock
-
 
1391
 * %pCr output the current rate of a clock
-
 
1392
 * %n is ignored
-
 
1393
 *
1365
 *
-
 
1366
 * See pointer() or Documentation/printk-formats.txt for more
-
 
1367
 * extensive description.
-
 
1368
 *
1394
 * ** Please update Documentation/printk-formats.txt when making changes **
1369
 * ** Please update the documentation in both places when making changes **
1395
 *
1370
 *
1396
 * The return value is the number of characters which would
1371
 * The return value is the number of characters which would
1397
 * be generated for the given input, excluding the trailing
1372
 * be generated for the given input, excluding the trailing
1398
 * '\0', as per ISO C99. If you want to have the exact
1373
 * '\0', as per ISO C99. If you want to have the exact
1399
 * number of characters written into @buf as return value
1374
 * number of characters written into @buf as return value
Line 1488... Line 1463...
1488
				*str = '%';
1463
				*str = '%';
1489
			++str;
1464
			++str;
1490
			break;
1465
			break;
Line 1491... Line 1466...
1491
 
1466
 
-
 
1467
		case FORMAT_TYPE_INVALID:
-
 
1468
			/*
-
 
1469
			 * Presumably the arguments passed gcc's type
-
 
1470
			 * checking, but there is no safe or sane way
1492
		case FORMAT_TYPE_INVALID:
1471
			 * for us to continue parsing the format and
-
 
1472
			 * fetching from the va_list; the remaining
1493
			if (str < end)
1473
			 * specifiers and arguments would be out of
1494
				*str = '%';
1474
			 * sync.
1495
			++str;
1475
			 */
Line 1496... Line 1476...
1496
			break;
1476
			goto out;
1497
 
1477
 
1498
		default:
1478
		default:
1499
			switch (spec.type) {
1479
			switch (spec.type) {
Line 1536... Line 1516...
1536
 
1516
 
1537
			str = number(str, end, num, spec);
1517
			str = number(str, end, num, spec);
1538
		}
1518
		}
Line -... Line 1519...
-
 
1519
	}
1539
	}
1520
 
1540
 
1521
out:
1541
	if (size > 0) {
1522
	if (size > 0) {
1542
		if (str < end)
1523
		if (str < end)
1543
			*str = '\0';
1524
			*str = '\0';