Print this page
10101 audio tools need smatch fixes


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 




  26 /* Command-line audio record utility */
  27 
  28 #include <stdio.h>
  29 #include <libgen.h>
  30 #include <errno.h>
  31 #include <ctype.h>
  32 #include <math.h>
  33 #include <stdlib.h>
  34 #include <unistd.h>
  35 #include <string.h>
  36 #include <strings.h>
  37 #include <locale.h>
  38 #include <fcntl.h>
  39 #include <signal.h>
  40 #include <limits.h>       /* All occurances of INT_MAX used to be ~0  (by MCA) */
  41 #include <sys/types.h>
  42 #include <sys/file.h>
  43 #include <sys/stat.h>
  44 #include <sys/param.h>
  45 #include <stropts.h>


 756                 drate = 8000.0;
 757         } else {
 758                 /* just do an atof */
 759                 drate = atof(s);
 760 
 761                 /*
 762                  * if the first non-digit is a "k" multiply by 1000,
 763                  * if it's an "h", leave it alone. anything else,
 764                  * return an error.
 765                  */
 766 
 767                 /*
 768                  * XXX bug alert: could have multiple "." in string
 769                  * and mess things up.
 770                  */
 771                 for (cp = s; *cp && (isdigit(*cp) || (*cp == '.')); cp++)
 772                         /* NOP */;
 773                 if (*cp != NULL) {
 774                         if ((*cp == 'k') || (*cp == 'K')) {
 775                                 drate *= 1000.0;
 776                         } else if ((*cp != 'h') || (*cp != 'H')) {
 777                                 /* bogus! */
 778                                 Error(stderr,
 779                                     MGET("invalid sample rate: %s\n"), s);
 780                                 return (1);
 781                         }
 782                 }
 783 
 784         }
 785 
 786         *rate = irint(drate);
 787         return (0);
 788 }


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2018, Joyent, Inc.
  28  */
  29 
  30 /* Command-line audio record utility */
  31 
  32 #include <stdio.h>
  33 #include <libgen.h>
  34 #include <errno.h>
  35 #include <ctype.h>
  36 #include <math.h>
  37 #include <stdlib.h>
  38 #include <unistd.h>
  39 #include <string.h>
  40 #include <strings.h>
  41 #include <locale.h>
  42 #include <fcntl.h>
  43 #include <signal.h>
  44 #include <limits.h>       /* All occurances of INT_MAX used to be ~0  (by MCA) */
  45 #include <sys/types.h>
  46 #include <sys/file.h>
  47 #include <sys/stat.h>
  48 #include <sys/param.h>
  49 #include <stropts.h>


 760                 drate = 8000.0;
 761         } else {
 762                 /* just do an atof */
 763                 drate = atof(s);
 764 
 765                 /*
 766                  * if the first non-digit is a "k" multiply by 1000,
 767                  * if it's an "h", leave it alone. anything else,
 768                  * return an error.
 769                  */
 770 
 771                 /*
 772                  * XXX bug alert: could have multiple "." in string
 773                  * and mess things up.
 774                  */
 775                 for (cp = s; *cp && (isdigit(*cp) || (*cp == '.')); cp++)
 776                         /* NOP */;
 777                 if (*cp != NULL) {
 778                         if ((*cp == 'k') || (*cp == 'K')) {
 779                                 drate *= 1000.0;
 780                         } else if ((*cp != 'h') && (*cp != 'H')) {
 781                                 /* bogus! */
 782                                 Error(stderr,
 783                                     MGET("invalid sample rate: %s\n"), s);
 784                                 return (1);
 785                         }
 786                 }
 787 
 788         }
 789 
 790         *rate = irint(drate);
 791         return (0);
 792 }