rem: if (restore_cwd (&top->u.saved_cwd)) error (EXIT_FAILURE, errno, _("failed to return to initial working directory"));
add: if (restore_cwd (&cwd_state->saved_cwd) != 0) {  cwd_state->saved_errno = errno; }
context: AD_pop_and_chdir (Dirstack_state *ds){  /* Get the name of the current directory from the top of the stack.  */  char *dir = top_dir (ds);  enum RM_status old_status = AD_stack_top(ds)->status;  struct stat sb;  struct AD_ent *top;  AD_stack_pop (ds);  /* Propagate any failure to parent.  */  UPDATE_STATUS (AD_stack_top(ds)->status, old_status);  assert (AD_stack_height (ds));  top = AD_stack_top (ds);  if (1 < AD_stack_height (ds))    {      /* We can give a better diagnostic here, since the target is relative. */      if (chdir (".."))	{	  error (EXIT_FAILURE, errno,		 _("cannot chdir from %s to .."),		 quote (full_filename (".")));	}    }  else    {      if (restore_cwd (&top->u.saved_cwd))	error (EXIT_FAILURE, errno,	       _("failed to return to initial working directory"));    }  if (lstat (".", &sb))    error (EXIT_FAILURE, errno,	   _("cannot lstat `.' in %s"), quote (full_filename (".")));  if (1 < AD_stack_height (ds))    {      /*  Ensure that post-chdir dev/ino match the stored ones.  */      if ( ! SAME_INODE (sb, top->u.a))	error (EXIT_FAILURE, 0,	       _("%s changed dev/ino"), quote (full_filename (".")));    }  return dir;}