@@ -475,20 +475,20 @@ static int request_handler_entries(
475475
476476 r = open_journal (m );
477477 if (r < 0 )
478- return mhd_respondf (connection , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to open journal: %s\n" , strerror ( - r ) );
478+ return mhd_respondf (connection , r , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to open journal: %m" );
479479
480480 if (request_parse_accept (m , connection ) < 0 )
481- return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Failed to parse Accept header.\n " );
481+ return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Failed to parse Accept header." );
482482
483483 if (request_parse_range (m , connection ) < 0 )
484- return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Failed to parse Range header.\n " );
484+ return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Failed to parse Range header." );
485485
486486 if (request_parse_arguments (m , connection ) < 0 )
487- return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Failed to parse URL arguments.\n " );
487+ return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Failed to parse URL arguments." );
488488
489489 if (m -> discrete ) {
490490 if (!m -> cursor )
491- return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Discrete seeks require a cursor specification.\n " );
491+ return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Discrete seeks require a cursor specification." );
492492
493493 m -> n_entries = 1 ;
494494 m -> n_entries_set = true;
@@ -501,7 +501,7 @@ static int request_handler_entries(
501501 else if (m -> n_skip < 0 )
502502 r = sd_journal_seek_tail (m -> journal );
503503 if (r < 0 )
504- return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Failed to seek in journal.\n " );
504+ return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Failed to seek in journal." );
505505
506506 response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN , 4 * 1024 , request_reader_entries , m , NULL );
507507 if (!response )
@@ -633,14 +633,14 @@ static int request_handler_fields(
633633
634634 r = open_journal (m );
635635 if (r < 0 )
636- return mhd_respondf (connection , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to open journal: %s\n" , strerror ( - r ) );
636+ return mhd_respondf (connection , r , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to open journal: %m" );
637637
638638 if (request_parse_accept (m , connection ) < 0 )
639- return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Failed to parse Accept header.\n " );
639+ return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Failed to parse Accept header." );
640640
641641 r = sd_journal_query_unique (m -> journal , field );
642642 if (r < 0 )
643- return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Failed to query unique fields.\n " );
643+ return mhd_respond (connection , MHD_HTTP_BAD_REQUEST , "Failed to query unique fields." );
644644
645645 response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN , 4 * 1024 , request_reader_fields , m , NULL );
646646 if (!response )
@@ -699,10 +699,10 @@ static int request_handler_file(
699699
700700 fd = open (path , O_RDONLY |O_CLOEXEC );
701701 if (fd < 0 )
702- return mhd_respondf (connection , MHD_HTTP_NOT_FOUND , "Failed to open file %s: %m\n " , path );
702+ return mhd_respondf (connection , errno , MHD_HTTP_NOT_FOUND , "Failed to open file %s: %m" , path );
703703
704704 if (fstat (fd , & st ) < 0 )
705- return mhd_respondf (connection , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to stat file: %m\n " );
705+ return mhd_respondf (connection , errno , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to stat file: %m" );
706706
707707 response = MHD_create_response_from_fd_at_offset64 (st .st_size , fd , 0 );
708708 if (!response )
@@ -766,27 +766,27 @@ static int request_handler_machine(
766766
767767 r = open_journal (m );
768768 if (r < 0 )
769- return mhd_respondf (connection , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to open journal: %s\n" , strerror ( - r ) );
769+ return mhd_respondf (connection , r , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to open journal: %m" );
770770
771771 r = sd_id128_get_machine (& mid );
772772 if (r < 0 )
773- return mhd_respondf (connection , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to determine machine ID: %s\n" , strerror ( - r ) );
773+ return mhd_respondf (connection , r , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to determine machine ID: %m" );
774774
775775 r = sd_id128_get_boot (& bid );
776776 if (r < 0 )
777- return mhd_respondf (connection , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to determine boot ID: %s\n" , strerror ( - r ) );
777+ return mhd_respondf (connection , r , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to determine boot ID: %m" );
778778
779779 hostname = gethostname_malloc ();
780780 if (!hostname )
781781 return respond_oom (connection );
782782
783783 r = sd_journal_get_usage (m -> journal , & usage );
784784 if (r < 0 )
785- return mhd_respondf (connection , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to determine disk usage: %s\n" , strerror ( - r ) );
785+ return mhd_respondf (connection , r , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to determine disk usage: %s" );
786786
787787 r = sd_journal_get_cutoff_realtime_usec (m -> journal , & cutoff_from , & cutoff_to );
788788 if (r < 0 )
789- return mhd_respondf (connection , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to determine disk usage: %s\n" , strerror ( - r ) );
789+ return mhd_respondf (connection , r , MHD_HTTP_INTERNAL_SERVER_ERROR , "Failed to determine disk usage: %s" );
790790
791791 if (parse_env_file ("/etc/os-release" , NEWLINE , "PRETTY_NAME" , & os_name , NULL ) == - ENOENT )
792792 (void ) parse_env_file ("/usr/lib/os-release" , NEWLINE , "PRETTY_NAME" , & os_name , NULL );
@@ -844,8 +844,7 @@ static int request_handler(
844844 assert (method );
845845
846846 if (!streq (method , "GET" ))
847- return mhd_respond (connection , MHD_HTTP_NOT_ACCEPTABLE ,
848- "Unsupported method.\n" );
847+ return mhd_respond (connection , MHD_HTTP_NOT_ACCEPTABLE , "Unsupported method." );
849848
850849
851850 if (!* connection_cls ) {
@@ -875,7 +874,7 @@ static int request_handler(
875874 if (streq (url , "/machine" ))
876875 return request_handler_machine (connection , * connection_cls );
877876
878- return mhd_respond (connection , MHD_HTTP_NOT_FOUND , "Not found.\n " );
877+ return mhd_respond (connection , MHD_HTTP_NOT_FOUND , "Not found." );
879878}
880879
881880static void help (void ) {
0 commit comments