MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / checksum_format_specifier

Function checksum_format_specifier

extra/comp_err.c:728–775  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

726*/
727
728static ha_checksum checksum_format_specifier(const char* msg)
729{
730 ha_checksum chksum= 0;
731 const uchar* p= (const uchar*) msg;
732 const uchar* start= NULL;
733 uint32 num_format_specifiers= 0;
734 while (*p)
735 {
736
737 if (*p == '%')
738 {
739 start= p+1; /* Entering format specifier */
740 num_format_specifiers++;
741 }
742 else if (start)
743 {
744 switch(*p)
745 {
746 case 'd':
747 case 'u':
748 case 'x':
749 case 's':
750 chksum= my_checksum(chksum, (uchar*) start, (uint) (p + 1 - start));
751 start= 0; /* Not in format specifier anymore */
752 break;
753
754 default:
755 break;
756 }
757 }
758
759 p++;
760 }
761
762 if (start)
763 {
764 /* Still inside a format specifier after end of string */
765
766 fprintf(stderr, "Still inside formatspecifier after end of string"
767 " in'%s'\n", msg);
768 DBUG_ASSERT(start==0);
769 }
770
771 /* Add number of format specifiers to checksum as extra safeguard */
772 chksum+= num_format_specifiers;
773
774 return chksum;
775}
776
777
778/*

Callers 1

check_message_formatFunction · 0.85

Calls 1

my_checksumFunction · 0.85

Tested by

no test coverage detected