Skip to content

Commit c8b5a29

Browse files
committed
Remove unneeded type casts
This removes unneded type casts to (char*) and (const char*). Signed-off-by: Stefan Weil <[email protected]>
1 parent b502bbf commit c8b5a29

File tree

9 files changed

+24
-29
lines changed

9 files changed

+24
-29
lines changed

src/api/pdfrenderer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void TessPDFRenderer::AppendPDFObjectDIY(size_t objectsize) {
196196

197197
void TessPDFRenderer::AppendPDFObject(const char *data) {
198198
AppendPDFObjectDIY(strlen(data));
199-
AppendString((const char *)data);
199+
AppendString(data);
200200
}
201201

202202
// Helper function to prevent us from accidentally writing

src/ccutil/clst.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const void *, const void *)) {
149149
}
150150

151151
/* Sort the pointer array */
152-
qsort ((char *) base, count, sizeof (*base), comparator);
152+
qsort(base, count, sizeof(*base), comparator);
153153

154154
/* Rebuild the list from the sorted pointers */
155155
current = base;

src/ccutil/elst.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const void *, const void *)) {
126126
}
127127

128128
/* Sort the pointer array */
129-
qsort ((char *) base, count, sizeof (*base), comparator);
129+
qsort(base, count, sizeof(*base), comparator);
130130

131131
/* Rebuild the list from the sorted pointers */
132132
current = base;

src/ccutil/elst2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const void *, const void *)) {
127127
}
128128

129129
/* Sort the pointer array */
130-
qsort ((char *) base, count, sizeof (*base), comparator);
130+
qsort(base, count, sizeof(*base), comparator);
131131

132132
/* Rebuild the list from the sorted pointers */
133133
current = base;

src/classify/adaptive.cpp

+12-13
Original file line numberDiff line numberDiff line change
@@ -415,25 +415,25 @@ void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs) {
415415
int i;
416416

417417
/* first write high level adapted class structure */
418-
fwrite ((char *) Class, sizeof (ADAPT_CLASS_STRUCT), 1, File);
418+
fwrite(Class, sizeof(ADAPT_CLASS_STRUCT), 1, File);
419419

420420
/* then write out the definitions of the permanent protos and configs */
421-
fwrite ((char *) Class->PermProtos, sizeof (uint32_t),
422-
WordsInVectorOfSize (MAX_NUM_PROTOS), File);
423-
fwrite ((char *) Class->PermConfigs, sizeof (uint32_t),
424-
WordsInVectorOfSize (MAX_NUM_CONFIGS), File);
421+
fwrite(Class->PermProtos, sizeof(uint32_t),
422+
WordsInVectorOfSize(MAX_NUM_PROTOS), File);
423+
fwrite(Class->PermConfigs, sizeof(uint32_t),
424+
WordsInVectorOfSize(MAX_NUM_CONFIGS), File);
425425

426426
/* then write out the list of temporary protos */
427427
NumTempProtos = count (Class->TempProtos);
428-
fwrite ((char *) &NumTempProtos, sizeof (int), 1, File);
428+
fwrite(&NumTempProtos, sizeof(int), 1, File);
429429
TempProtos = Class->TempProtos;
430430
iterate (TempProtos) {
431431
void* proto = first_node(TempProtos);
432-
fwrite ((char *) proto, sizeof (TEMP_PROTO_STRUCT), 1, File);
432+
fwrite(proto, sizeof(TEMP_PROTO_STRUCT), 1, File);
433433
}
434434

435435
/* then write out the adapted configs */
436-
fwrite ((char *) &NumConfigs, sizeof (int), 1, File);
436+
fwrite(&NumConfigs, sizeof(int), 1, File);
437437
for (i = 0; i < NumConfigs; i++)
438438
if (test_bit (Class->PermConfigs, i))
439439
WritePermConfig (File, Class->Config[i].Perm);
@@ -457,7 +457,7 @@ void Classify::WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) {
457457
int i;
458458

459459
/* first write the high level adaptive template struct */
460-
fwrite ((char *) Templates, sizeof (ADAPT_TEMPLATES_STRUCT), 1, File);
460+
fwrite(Templates, sizeof(ADAPT_TEMPLATES_STRUCT), 1, File);
461461

462462
/* then write out the basic integer templates */
463463
WriteIntTemplates (File, Templates->Templates, unicharset);
@@ -487,7 +487,7 @@ void WritePermConfig(FILE *File, PERM_CONFIG Config) {
487487
assert (Config != nullptr);
488488
while (Config->Ambigs[NumAmbigs] > 0) ++NumAmbigs;
489489

490-
fwrite((char *) &NumAmbigs, sizeof(uint8_t), 1, File);
490+
fwrite(&NumAmbigs, sizeof(uint8_t), 1, File);
491491
fwrite(Config->Ambigs, sizeof(UNICHAR_ID), NumAmbigs, File);
492492
fwrite(&(Config->FontinfoId), sizeof(int), 1, File);
493493
} /* WritePermConfig */
@@ -506,8 +506,7 @@ void WritePermConfig(FILE *File, PERM_CONFIG Config) {
506506
void WriteTempConfig(FILE *File, TEMP_CONFIG Config) {
507507
assert (Config != nullptr);
508508

509-
fwrite ((char *) Config, sizeof (TEMP_CONFIG_STRUCT), 1, File);
510-
fwrite ((char *) Config->Protos, sizeof (uint32_t),
511-
Config->ProtoVectorSize, File);
509+
fwrite(Config, sizeof (TEMP_CONFIG_STRUCT), 1, File);
510+
fwrite(Config->Protos, sizeof (uint32_t), Config->ProtoVectorSize, File);
512511

513512
} /* WriteTempConfig */

src/classify/cluster.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ SAMPLE* MakeSample(CLUSTERER * Clusterer, const float* Feature,
472472

473473
// add the sample to the KD tree - keep track of the total # of samples
474474
Clusterer->NumberOfSamples++;
475-
KDStore (Clusterer->KDTree, Sample->Mean, (char *) Sample);
475+
KDStore(Clusterer->KDTree, Sample->Mean, Sample);
476476
if (CharID >= Clusterer->NumChar)
477477
Clusterer->NumChar = CharID + 1;
478478

src/classify/intproto.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -1071,14 +1071,13 @@ void Classify::WriteIntTemplates(FILE *File, INT_TEMPLATES Templates,
10711071

10721072
/* then write out the proto lengths */
10731073
if (MaxNumIntProtosIn (Class) > 0) {
1074-
fwrite ((char *) (Class->ProtoLengths), sizeof (uint8_t),
1075-
MaxNumIntProtosIn (Class), File);
1074+
fwrite(Class->ProtoLengths, sizeof(uint8_t),
1075+
MaxNumIntProtosIn(Class), File);
10761076
}
10771077

10781078
/* then write out the proto sets */
10791079
for (j = 0; j < Class->NumProtoSets; j++)
1080-
fwrite ((char *) Class->ProtoSets[j],
1081-
sizeof (PROTO_SET_STRUCT), 1, File);
1080+
fwrite(Class->ProtoSets[j], sizeof(PROTO_SET_STRUCT), 1, File);
10821081

10831082
/* then write the fonts info */
10841083
fwrite(&Class->font_set_id, sizeof(int), 1, File);

src/opencl/openclwrapper.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ int OpenclDevice::RegistOpenclKernel() {
775775
gpuEnv.mnFileCount = 0; // argc;
776776
gpuEnv.mnKernelCount = 0UL;
777777

778-
AddKernelConfig(1, (const char*)"oclAverageSub1");
778+
AddKernelConfig(1, "oclAverageSub1");
779779
return 0;
780780
}
781781

@@ -846,14 +846,13 @@ int OpenclDevice::BinaryGenerated(const char* clFileName, FILE** fhandle) {
846846
unsigned int i = 0;
847847
cl_int clStatus;
848848
int status = 0;
849-
char* str = nullptr;
850849
FILE* fd = nullptr;
851850
char fileName[256] = {0}, cl_name[128] = {0};
852851
char deviceName[1024];
853852
clStatus = clGetDeviceInfo(gpuEnv.mpArryDevsID[i], CL_DEVICE_NAME,
854853
sizeof(deviceName), deviceName, nullptr);
855854
CHECK_OPENCL(clStatus, "clGetDeviceInfo");
856-
str = (char*)strstr(clFileName, (char*)".cl");
855+
const char* str = strstr(clFileName, ".cl");
857856
memcpy(cl_name, clFileName, str - clFileName);
858857
cl_name[str - clFileName] = '\0';
859858
sprintf(fileName, "%s-%s.bin", cl_name, deviceName);
@@ -897,7 +896,6 @@ int OpenclDevice::GeneratBinFromKernelSource(cl_program program,
897896
unsigned int i = 0;
898897
cl_int clStatus;
899898
cl_uint numDevices;
900-
char* str = nullptr;
901899

902900
clStatus = clGetProgramInfo(program, CL_PROGRAM_NUM_DEVICES,
903901
sizeof(numDevices), &numDevices, nullptr);
@@ -949,7 +947,7 @@ int OpenclDevice::GeneratBinFromKernelSource(cl_program program,
949947
sizeof(deviceName), deviceName, nullptr);
950948
CHECK_OPENCL(clStatus, "clGetDeviceInfo");
951949

952-
str = (char*)strstr(clFileName, (char*)".cl");
950+
const char* str = strstr(clFileName, ".cl");
953951
memcpy(cl_name, clFileName, str - clFileName);
954952
cl_name[str - clFileName] = '\0';
955953
sprintf(fileName, "%s-%s.bin", cl_name, deviceName);

src/viewer/svutil.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ static int GetAddrInfoNonLinux(const char* hostname, int port,
364364

365365
// Fill in the appropriate variables to be able to connect to the server.
366366
address->sin_family = name->h_addrtype;
367-
memcpy((char *) &address->sin_addr.s_addr,
368-
name->h_addr_list[0], name->h_length);
367+
memcpy(&address->sin_addr.s_addr, name->h_addr_list[0], name->h_length);
369368
address->sin_port = htons(port);
370369
return 0;
371370
}

0 commit comments

Comments
 (0)