@@ -372,16 +372,16 @@ EXPORT_SYMBOL(seq_release);
372372 * @esc: set of characters that need escaping
373373 *
374374 * Puts string into buffer, replacing each occurrence of character from
375- * @esc with usual octal escape. Returns 0 in case of success, -1 - in
376- * case of overflow .
375+ * @esc with usual octal escape.
376+ * Use seq_has_overflowed() to check for errors .
377377 */
378- int seq_escape (struct seq_file * m , const char * s , const char * esc )
378+ void seq_escape (struct seq_file * m , const char * s , const char * esc )
379379{
380380 char * end = m -> buf + m -> size ;
381- char * p ;
381+ char * p ;
382382 char c ;
383383
384- for (p = m -> buf + m -> count ; (c = * s ) != '\0' && p < end ; s ++ ) {
384+ for (p = m -> buf + m -> count ; (c = * s ) != '\0' && p < end ; s ++ ) {
385385 if (!strchr (esc , c )) {
386386 * p ++ = c ;
387387 continue ;
@@ -394,39 +394,34 @@ int seq_escape(struct seq_file *m, const char *s, const char *esc)
394394 continue ;
395395 }
396396 seq_set_overflow (m );
397- return -1 ;
398- }
397+ return ;
398+ }
399399 m -> count = p - m -> buf ;
400- return 0 ;
401400}
402401EXPORT_SYMBOL (seq_escape );
403402
404- int seq_vprintf (struct seq_file * m , const char * f , va_list args )
403+ void seq_vprintf (struct seq_file * m , const char * f , va_list args )
405404{
406405 int len ;
407406
408407 if (m -> count < m -> size ) {
409408 len = vsnprintf (m -> buf + m -> count , m -> size - m -> count , f , args );
410409 if (m -> count + len < m -> size ) {
411410 m -> count += len ;
412- return 0 ;
411+ return ;
413412 }
414413 }
415414 seq_set_overflow (m );
416- return -1 ;
417415}
418416EXPORT_SYMBOL (seq_vprintf );
419417
420- int seq_printf (struct seq_file * m , const char * f , ...)
418+ void seq_printf (struct seq_file * m , const char * f , ...)
421419{
422- int ret ;
423420 va_list args ;
424421
425422 va_start (args , f );
426- ret = seq_vprintf (m , f , args );
423+ seq_vprintf (m , f , args );
427424 va_end (args );
428-
429- return ret ;
430425}
431426EXPORT_SYMBOL (seq_printf );
432427
@@ -664,26 +659,25 @@ int seq_open_private(struct file *filp, const struct seq_operations *ops,
664659}
665660EXPORT_SYMBOL (seq_open_private );
666661
667- int seq_putc (struct seq_file * m , char c )
662+ void seq_putc (struct seq_file * m , char c )
668663{
669- if (m -> count < m -> size ) {
670- m -> buf [m -> count ++ ] = c ;
671- return 0 ;
672- }
673- return -1 ;
664+ if (m -> count >= m -> size )
665+ return ;
666+
667+ m -> buf [m -> count ++ ] = c ;
674668}
675669EXPORT_SYMBOL (seq_putc );
676670
677- int seq_puts (struct seq_file * m , const char * s )
671+ void seq_puts (struct seq_file * m , const char * s )
678672{
679673 int len = strlen (s );
680- if ( m -> count + len < m -> size ) {
681- memcpy (m -> buf + m -> count , s , len );
682- m -> count += len ;
683- return 0 ;
674+
675+ if (m -> count + len >= m -> size ) {
676+ seq_set_overflow ( m ) ;
677+ return ;
684678 }
685- seq_set_overflow ( m );
686- return -1 ;
679+ memcpy ( m -> buf + m -> count , s , len );
680+ m -> count += len ;
687681}
688682EXPORT_SYMBOL (seq_puts );
689683
@@ -694,8 +688,8 @@ EXPORT_SYMBOL(seq_puts);
694688 * This routine is very quick when you show lots of numbers.
695689 * In usual cases, it will be better to use seq_printf(). It's easier to read.
696690 */
697- int seq_put_decimal_ull (struct seq_file * m , char delimiter ,
698- unsigned long long num )
691+ void seq_put_decimal_ull (struct seq_file * m , char delimiter ,
692+ unsigned long long num )
699693{
700694 int len ;
701695
@@ -707,35 +701,33 @@ int seq_put_decimal_ull(struct seq_file *m, char delimiter,
707701
708702 if (num < 10 ) {
709703 m -> buf [m -> count ++ ] = num + '0' ;
710- return 0 ;
704+ return ;
711705 }
712706
713707 len = num_to_str (m -> buf + m -> count , m -> size - m -> count , num );
714708 if (!len )
715709 goto overflow ;
716710 m -> count += len ;
717- return 0 ;
711+ return ;
712+
718713overflow :
719714 seq_set_overflow (m );
720- return -1 ;
721715}
722716EXPORT_SYMBOL (seq_put_decimal_ull );
723717
724- int seq_put_decimal_ll (struct seq_file * m , char delimiter ,
725- long long num )
718+ void seq_put_decimal_ll (struct seq_file * m , char delimiter , long long num )
726719{
727720 if (num < 0 ) {
728721 if (m -> count + 3 >= m -> size ) {
729722 seq_set_overflow (m );
730- return -1 ;
723+ return ;
731724 }
732725 if (delimiter )
733726 m -> buf [m -> count ++ ] = delimiter ;
734727 num = - num ;
735728 delimiter = '-' ;
736729 }
737- return seq_put_decimal_ull (m , delimiter , num );
738-
730+ seq_put_decimal_ull (m , delimiter , num );
739731}
740732EXPORT_SYMBOL (seq_put_decimal_ll );
741733
0 commit comments