On Thu, Mar 19, 2026 at 10:48:38PM +0100, David Hildenbrand (Arm) wrote:
> 
> > +
> > +void write_file(const char *path, const char *buf, size_t buflen)
> > +{
> > +   int fd;
> > +   ssize_t numwritten;
> > +
> > +   fd = open(path, O_WRONLY);
> > +   if (fd == -1)
> > +           ksft_exit_fail_msg("%s open failed: %s\n", path, 
> > strerror(errno));
> > +
> > +   numwritten = write(fd, buf, buflen - 1);
> > +   close(fd);
> > +   if (numwritten < 1)
> > +           ksft_exit_fail_msg("Write failed\n");
> I guess we could indeed test here easily for
> 
>       if (numwritten != buflen - 1)

Looks like you are right. AI provided other questions on this helper,
maybe I can append a patch in the series to do such robust improvement.

> 
> But then, we don't really expect only partial writes to succeed here.
> 
> Acked-by: David Hildenbrand (Arm) <[email protected]>
> 
> -- 
> Cheers,
> 
> David
> 


Reply via email to