rust_binder: add missing newlines to log messages
Subsystems (2)
PATCH 1/1 rust_binder: add missing newlines to log messages
The kernel printing macros don't append a newline automatically (with the way pr_*!() works), so the error message gets concatenated onto the next line in the kernel log during these warnings, errors, etc. Add '\n' to the end of error, warning, and debug messages.
Suggested-by Miguel Ojeda <[email protected]>
Signed-off-by Advaith Vecham <[email protected]>
--- drivers/android/binder/allocation.rs | 2 +- drivers/android/binder/context.rs | 6 +++--- drivers/android/binder/node.rs | 2 +- drivers/android/binder/page_range.rs | 12 ++++++------ drivers/android/binder/process.rs | 14 +++++++------- drivers/android/binder/range_alloc/tree.rs | 2 +- drivers/android/binder/thread.rs | 14 +++++++------- drivers/android/binder/transaction.rs | 8 ++++---- 8 files changed, 30 insertions(+), 30 deletions(-)
drivers/android/binder/allocation.rs +1 -1
@@ -286,7 +286,7 @@ fn drop(&mut self) {if info.clear_on_free {if let Err (e) = self.fill_zero () { -pr_warn! ("Failed to clear data on free: {:?}" , e); +pr_warn! ("Failed to clear data on free: {:?}\n" , e); } } }
drivers/android/binder/context.rs +3 -3
@@ -80,7 +80,7 @@ pub(crate) fn deregister(self: &Arc<Self>) {pub (crate )fn register_process (self: &Arc <Self >, proc:Arc <Process >) ->Result {if !Arc ::ptr_eq (self, &proc.ctx) { -pr_err! ("Context::register_process called on the wrong context." ); +pr_err! ("Context::register_process called on the wrong context.\n" );return Err (EINVAL ); } self.manager.lock ().all_procs.push (proc,GFP_KERNEL )?;
@@ -89,7 +89,7 @@ pub(crate) fn register_process(self: &Arc<Self>, proc: Arc<Process>) -> Result {pub (crate )fn deregister_process (self: &Arc <Self >, proc: &Arc <Process >) {if !Arc ::ptr_eq (self, &proc.ctx) { -pr_err! ("Context::deregister_process called on the wrong context." ); +pr_err! ("Context::deregister_process called on the wrong context.\n" );return ; }let mut manager = self.manager.lock ();
@@ -110,7 +110,7 @@ pub(crate) fn deregister_process(self: &Arc<Self>, proc: &Arc<Process>) {pub (crate )fn set_manager_node (&self, node_ref:NodeRef ) ->Result {let mut manager = self.manager.lock ();if manager.node.is_some () { -pr_warn! ("BINDER_SET_CONTEXT_MGR already set" ); +pr_warn! ("BINDER_SET_CONTEXT_MGR already set\n" );return Err (EBUSY ); } security::binder_set_context_mgr (&node_ref.node.owner.cred)?;
drivers/android/binder/node.rs +1 -1
@@ -405,7 +405,7 @@ pub(crate) fn update_refcount_locked( !is_dead && !state.has_count }else {if state.count < count { -pr_err! ("Failure: refcount underflow!" ); +pr_err! ("Failure: refcount underflow!\n" );return None ; } state.count -= count;
drivers/android/binder/page_range.rs +6 -6
@@ -212,7 +212,7 @@ unsafe fn set_page(me: *mut PageInfo, page: Page) {// SAFETY: The pointer is valid for writing, so also valid for reading. if unsafe { (*ptr).is_some () } { -pr_err! ("set_page called when there is already a page" ); +pr_err! ("set_page called when there is already a page\n" );// SAFETY: We will initialize the page again below. unsafe { ptr::drop_in_place (ptr) }; }
@@ -300,11 +300,11 @@ pub(crate) fn register_with_vma(&self, vma: &virt::VmaNew) -> Result<usize> {let num_pages = num_bytes >>PAGE_SHIFT ;if !ptr::eq ::<Mm >(&*self.mm, &**vma.mm ()) { -pr_debug! ("Failed to register with vma: invalid vma->vm_mm" ); +pr_debug! ("Failed to register with vma: invalid vma->vm_mm\n" );return Err (EINVAL ); }if num_pages ==0 { -pr_debug! ("Failed to register with vma: size zero" ); +pr_debug! ("Failed to register with vma: size zero\n" );return Err (EINVAL ); }
@@ -325,7 +325,7 @@ pub(crate) fn register_with_vma(&self, vma: &virt::VmaNew) -> Result<usize> {let mut inner = self.lock.lock ();if inner.size >0 { -pr_debug! ("Failed to register with vma: already registered" ); +pr_debug! ("Failed to register with vma: already registered\n" );drop (inner);return Err (EBUSY ); }
@@ -380,7 +380,7 @@ pub(crate) fn use_range(&self, start: usize, end: usize) -> Result<()> {match unsafe { self.use_page_slow (i) } {Ok (()) => {}Err (err) => { -pr_warn! ("Error in use_page_slow: {:?}" , err); +pr_warn! ("Error in use_page_slow: {:?}\n" , err);return Err (err); } }
@@ -529,7 +529,7 @@ unsafe fn iterate<T>(&self, mut offset: usize, mut size: usize, mut cb: T) -> Re// duration of this call to `iterate`, so nobody will change the page. let page =unsafe {PageInfo ::get_page (page_info) };if page.is_none () { -pr_warn! ("Page is null!" ); +pr_warn! ("Page is null!\n" ); }let page = page.ok_or (EFAULT )?;cb (page, offset, available)?;
drivers/android/binder/process.rs +7 -7
@@ -324,7 +324,7 @@ pub(crate) fn death_delivered(&mut self, death: DArc<NodeDeath>) {if let Some (death) =ListArc ::try_from_arc_or_drop (death) { self.delivered_deaths.push_back (death); }else { -pr_warn! ("Notification added to `delivered_deaths` twice." ); +pr_warn! ("Notification added to `delivered_deaths` twice.\n" ); } }
@@ -701,7 +701,7 @@ fn get_current_thread(self: ArcBorrow<'_, Self>) -> Result<Arc<Thread>> {let id = {let current = kernel::current!();if self.task != current.group_leader () { -pr_err! ("get_current_thread was called from the wrong process." ); +pr_err! ("get_current_thread was called from the wrong process.\n" );return Err (EINVAL ); } current.pid ()
@@ -725,7 +725,7 @@ fn get_current_thread(self: ArcBorrow<'_, Self>) -> Result<Arc<Thread>> {Ok (ta) } rbtree::Entry::Occupied(_entry) => { -pr_err! ("Cannot create two threads with the same id." ); +pr_err! ("Cannot create two threads with the same id.\n" );Err (EINVAL ) } }
@@ -861,7 +861,7 @@ pub(crate) fn insert_or_update_handle(match refs.by_handle.entry (res.as_u32 ()) { rbtree::Entry ::Vacant (entry) =>break (res, entry), rbtree::Entry ::Occupied (_) => { -pr_err! ("Detected mismatch between handle_is_present and by_handle" ); +pr_err! ("Detected mismatch between handle_is_present and by_handle\n" ); res.acquire (); kernel::warn_on!(true );return Err (EINVAL );
@@ -1101,7 +1101,7 @@ pub(crate) fn buffer_alloc( ) { Ok(()) => {} Err(err) => { - pr_warn!("use_range failure {:?}", err); + pr_warn!("use_range failure {:?}\n", err); return Err(err.into()); } }
@@ -1516,7 +1516,7 @@ pub(crate) fn drop_outstanding_txn(&self) {let wake = {let mut inner = self.inner.lock ();if inner.outstanding_txns ==0 { -pr_err! ("outstanding_txns underflow" ); +pr_err! ("outstanding_txns underflow\n" );return ; } inner.outstanding_txns -=1 ;
@@ -1836,7 +1836,7 @@ fn new(thread: &'a Arc<Thread>, guard: &mut Guard<'_, ProcessInner, SpinLockBack// It is an error to hit this branch, and it should not be reachable. We try to do // something reasonable when the failure path happens. Most likely, the thread in // question will sleep forever. -pr_err! ("Same thread registered with `ready_threads` twice." ); +pr_err! ("Same thread registered with `ready_threads` twice.\n" ); }Self { thread } }
drivers/android/binder/range_alloc/tree.rs +1 -1
@@ -166,7 +166,7 @@ pub(crate) fn reserve_new(let (found_size, found_off, tree_node, free_tree_node) =match self.find_best_match (size) {None => { -pr_warn! ("ENOSPC from range_alloc.reserve_new - size: {}" , size); +pr_warn! ("ENOSPC from range_alloc.reserve_new - size: {}\n" , size);return Err (ENOSPC ); }Some (desc) => {
drivers/android/binder/thread.rs +7 -7
@@ -339,7 +339,7 @@ fn push_reply_work(&mut self, code: u32) -> PushWorkRes { work.set_error_code (code); self.push_work (work) }else { -pr_warn! ("Thread reply work is already in use." ); +pr_warn! ("Thread reply work is already in use.\n" );PushWorkRes ::Ok } }
@@ -350,7 +350,7 @@ fn push_return_work(&mut self, reply: u32) {// Not notifying: Reply to current thread. let _ = self.push_work (work); }else { -pr_warn! ("Thread return work is already in use." ); +pr_warn! ("Thread return work is already in use.\n" ); } }
@@ -884,7 +884,7 @@ fn translate_object( .read_all(&mut fda_bytes, GFP_KERNEL)?;if fds_len != fda_bytes.len () { -pr_err! ("UserSlice::read_all returned wrong length in BINDER_TYPE_FDA" ); +pr_err! ("UserSlice::read_all returned wrong length in BINDER_TYPE_FDA\n" );return Err (EINVAL .into ()); }
@@ -999,7 +999,7 @@ pub(crate) fn copy_transaction_data(let ctx =match security::SecurityCtx ::from_secid (secid) {Ok (ctx) => ctx,Err (err) => { -pr_warn! ("Failed to get security ctx for id {}: {:?}" , secid, err); +pr_warn! ("Failed to get security ctx for id {}: {:?}\n" , secid, err);return Err (err.into ()); } };
@@ -1233,7 +1233,7 @@ fn top_of_transaction_stack(&self) -> Result<Option<DArc<Transaction>>> {let inner = self.inner.lock ();if let Some (cur) = &inner.current_transaction {if core::ptr::eq (self, cur.from.as_ref ()) { -pr_warn! ("got new transaction with bad transaction stack" ); +pr_warn! ("got new transaction with bad transaction stack\n" );return Err (EINVAL ); }Ok (Some (cur.clone ()))
@@ -1562,7 +1562,7 @@ fn read(self: &Arc<Self>, req: &mut BinderWriteRead, wait: bool) -> Result {let mut has_noop_placeholder =false ;if req.read_consumed ==0 {if let Err (err) = writer.write_code (BR_NOOP ) { -pr_warn! ("Failure when writing BR_NOOP at beginning of buffer." ); +pr_warn! ("Failure when writing BR_NOOP at beginning of buffer.\n" );return Err (err); } has_noop_placeholder =true ;
@@ -1585,7 +1585,7 @@ fn read(self: &Arc<Self>, req: &mut BinderWriteRead, wait: bool) -> Result { Err(err) => {// Propagate the error if we haven't written anything else. if err !=EINTR && err !=EAGAIN { -pr_warn! ("Failure in work getter: {:?}" , err); +pr_warn! ("Failure in work getter: {:?}\n" , err); }if initial_len == writer.len () {return Err (err);
drivers/android/binder/transaction.rs +4 -4
@@ -176,14 +176,14 @@ pub(crate) fn new( Ok(alloc) => alloc, Err(err) => {if !err.is_dead () { -pr_warn! ("Failure in copy_transaction_data: {:?}" , err); +pr_warn! ("Failure in copy_transaction_data: {:?}\n" , err); }return Err (err); } };if info.is_oneway () {if from_parent.is_some () { -pr_warn! ("Oneway transaction should not be in a transaction stack." ); +pr_warn! ("Oneway transaction should not be in a transaction stack.\n" );return Err (EINVAL .into ()); } alloc.set_info_oneway_node (node_ref.node.clone ());
@@ -224,7 +224,7 @@ pub(crate) fn new_reply(match from.copy_transaction_data (to.clone (), info, info.debug_id, allow_fds,None ) {Ok (alloc) => alloc,Err (err) => { -pr_warn! ("Failure in copy_transaction_data: {:?}" , err); +pr_warn! ("Failure in copy_transaction_data: {:?}\n" , err);return Err (err); } };
@@ -384,7 +384,7 @@ pub(crate) fn submit(self: DLArc<Self>, info: &mut TransactionInfo) -> BinderResreturn Ok (()); } }else { -pr_err! ("Failed to submit oneway transaction to node." ); +pr_err! ("Failed to submit oneway transaction to node.\n" ); } }
Signature · 1 line
2.43.0
Alice Ryhl
maintainerQuoted 8 lines · Advaith Vecham
The kernel printing macros don't append a newline automatically (with the way pr_*!() works), so the error message gets concatenated onto the next line in the kernel log during these warnings, errors, etc. Add '\n' to the end of error, warning, and debug messages.
Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Advaith Vecham <[email protected]>
Thanks! Unfortunately my patch series that changes all calls to pr_*_ratelimited! already makes this change.
Alice