Show expected & received length in error messages (#277)

This commit is contained in:
Ritiek Malhotra 2020-07-17 15:04:18 +05:30 committed by GitHub
commit d4b4681a0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -116,7 +116,9 @@ int real_main(int argc, char *argv[])
QByteArray regist_key = parser.value(regist_key_option).toUtf8();
if(regist_key.length() > sizeof(ChiakiConnectInfo::regist_key))
{
printf("Given regist key is too long.\n");
printf("Given regist key is too long (expected size <=%llu, got %d)\n",
(unsigned long long)sizeof(ChiakiConnectInfo::regist_key),
regist_key.length());
return 1;
}
regist_key += QByteArray(sizeof(ChiakiConnectInfo::regist_key) - regist_key.length(), 0);
@ -124,6 +126,9 @@ int real_main(int argc, char *argv[])
QByteArray morning = QByteArray::fromBase64(parser.value(morning_option).toUtf8());
if(morning.length() != sizeof(ChiakiConnectInfo::morning))
{
printf("Given morning has invalid size (expected %llu, got %d)\n",
(unsigned long long)sizeof(ChiakiConnectInfo::morning),
morning.length());
printf("Given morning has invalid size (expected %llu)", (unsigned long long)sizeof(ChiakiConnectInfo::morning));
return 1;
}