File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
compiler-rt/test/sanitizer_common/TestCases/Linux Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 77#include < errno.h>
88#include < netdb.h>
99#include < stdio.h>
10+ #include < string>
11+
12+ std::string any_name;
13+ int total_count;
1014
1115void print_protoent (protoent *curr_entry) {
1216 fprintf (stderr, " %s (%d)\n " , curr_entry->p_name , curr_entry->p_proto );
@@ -23,6 +27,8 @@ void print_all_protoent() {
2327 protoent *curr_entry;
2428
2529 while (getprotoent_r (&entry, buf, sizeof (buf), &curr_entry) != ENOENT && curr_entry) {
30+ ++total_count;
31+ any_name = curr_entry->p_name ;
2632 print_protoent (curr_entry);
2733 }
2834}
@@ -51,10 +57,13 @@ int main() {
5157 fprintf (stderr, " All protoent\n " );
5258 print_all_protoent ();
5359
60+ if (!total_count)
61+ return 0 ;
62+
5463 fprintf (stderr, " Protoent by name\n " );
55- print_protoent_by_name (" ipv6 " );
64+ print_protoent_by_name (any_name. c_str () );
5665
5766 fprintf (stderr, " Protoent by num\n " );
58- print_protoent_by_num (17 );
67+ print_protoent_by_num (total_count / 2 );
5968 return 0 ;
6069}
You can’t perform that action at this time.
0 commit comments