Print this page
12326 hal: the value of *n_speeds should increase rather than the pointer
   1 /***************************************************************************
   2  *
   3  * cdutils.c : CD/DVD utilities
   4  *
   5  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
   6  * Use is subject to license terms.
   7  *
   8  * Licensed under the Academic Free License version 2.1
   9  *
  10  **************************************************************************/
  11 
  12 
  13 #ifdef HAVE_CONFIG_H
  14 #  include <config.h>
  15 #endif
  16 
  17 #include <stdio.h>
  18 #include <sys/types.h>
  19 #include <sys/scsi/impl/uscsi.h>
  20 #include <string.h>
  21 #include <strings.h>
  22 #include <unistd.h>
  23 #include <stdlib.h>
  24 #include <errno.h>
  25 #include <fcntl.h>


 293                 return;
 294         }
 295 
 296         for (i = 0; i < n; i++, p += 4) {
 297                 current = &(*speeds_mem)[i];
 298                 current->val = GET16(p);
 299 
 300                 /* keep the list sorted */
 301                 skip = B_FALSE;
 302                 for (nextp = speeds; *nextp != NULL; nextp = &((*nextp)->next)) {
 303                         if (current->val == (*nextp)->val) {
 304                                 skip = B_TRUE; /* skip duplicates */
 305                                 break;
 306                         } else if (current->val > (*nextp)->val) {
 307                                 break;
 308                         }
 309                 }
 310                 if (!skip) {
 311                         current->next = *nextp;
 312                         *nextp = current;
 313                         *n_speeds++;
 314                 }
 315         }
 316 }
 317 
 318 void
 319 get_read_write_speeds(int fd, int *read_speed, int *write_speed,
 320     intlist_t **speeds, int *n_speeds, intlist_t **speeds_mem)
 321 {
 322         int page_len;
 323         uchar_t p[254];
 324         int n; /* number of write speed performance descriptor blocks */
 325 
 326         *read_speed = *write_speed = 0;
 327         *speeds = *speeds_mem = NULL;
 328 
 329         if (!get_mode_page(fd, 0x2A, 0, sizeof (p), p, &page_len)) {
 330                 return;
 331         }
 332 
 333         if (page_len > 8) {


   1 /***************************************************************************
   2  *
   3  * cdutils.c : CD/DVD utilities
   4  *
   5  * Copyright 2006, 2015, Oracle and/or its affiliates. All rights reserved.
   6  * Use is subject to license terms.
   7  *
   8  * Licensed under the Academic Free License version 2.1
   9  *
  10  **************************************************************************/
  11 
  12 
  13 #ifdef HAVE_CONFIG_H
  14 #  include <config.h>
  15 #endif
  16 
  17 #include <stdio.h>
  18 #include <sys/types.h>
  19 #include <sys/scsi/impl/uscsi.h>
  20 #include <string.h>
  21 #include <strings.h>
  22 #include <unistd.h>
  23 #include <stdlib.h>
  24 #include <errno.h>
  25 #include <fcntl.h>


 293                 return;
 294         }
 295 
 296         for (i = 0; i < n; i++, p += 4) {
 297                 current = &(*speeds_mem)[i];
 298                 current->val = GET16(p);
 299 
 300                 /* keep the list sorted */
 301                 skip = B_FALSE;
 302                 for (nextp = speeds; *nextp != NULL; nextp = &((*nextp)->next)) {
 303                         if (current->val == (*nextp)->val) {
 304                                 skip = B_TRUE; /* skip duplicates */
 305                                 break;
 306                         } else if (current->val > (*nextp)->val) {
 307                                 break;
 308                         }
 309                 }
 310                 if (!skip) {
 311                         current->next = *nextp;
 312                         *nextp = current;
 313                         (*n_speeds)++;
 314                 }
 315         }
 316 }
 317 
 318 void
 319 get_read_write_speeds(int fd, int *read_speed, int *write_speed,
 320     intlist_t **speeds, int *n_speeds, intlist_t **speeds_mem)
 321 {
 322         int page_len;
 323         uchar_t p[254];
 324         int n; /* number of write speed performance descriptor blocks */
 325 
 326         *read_speed = *write_speed = 0;
 327         *speeds = *speeds_mem = NULL;
 328 
 329         if (!get_mode_page(fd, 0x2A, 0, sizeof (p), p, &page_len)) {
 330                 return;
 331         }
 332 
 333         if (page_len > 8) {